Skip to content

Commit 917c04b

Browse files
committed
fix: quality lints
1 parent e1810ea commit 917c04b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

opaque_keys/edx/locator.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,7 @@ class LibraryUsageLocatorV2(CheckFieldMixin, UsageKeyV2):
15591559
CANONICAL_NAMESPACE = 'lb' # "Library Block"
15601560
KEY_FIELDS = ('lib_key', 'block_type', 'usage_id')
15611561
lib_key: LibraryLocatorV2
1562+
block_type: str
15621563
usage_id: str
15631564

15641565
__slots__ = KEY_FIELDS
@@ -1731,19 +1732,29 @@ def context_key(self) -> LibraryLocatorV2:
17311732

17321733
@property
17331734
def lib_usage_key(self) -> LibraryContainerUsageLocator:
1735+
"""
1736+
Creates a usage key from this locator.
1737+
"""
17341738
usage_key = LibraryContainerUsageLocator(
1735-
lib_key=self.library_key,
1739+
lib_key=self.lib_key,
17361740
block_type=self.container_type,
17371741
usage_id=self.container_id,
17381742
)
17391743
return usage_key
17401744

17411745
@classmethod
17421746
def from_usage_key(cls, usage_key: LibraryContainerUsageLocator) -> Self:
1747+
"""
1748+
Initializes a container locator from a container usage key.
1749+
"""
17431750
if not isinstance(usage_key, LibraryContainerUsageLocator):
17441751
raise InvalidKeyError(cls, str(usage_key))
17451752
try:
1746-
key_str = str(usage_key).replace(LibraryContainerUsageLocator.CANONICAL_NAMESPACE, cls.CANONICAL_NAMESPACE, 1)
1753+
key_str = str(usage_key).replace(
1754+
LibraryContainerUsageLocator.CANONICAL_NAMESPACE,
1755+
cls.CANONICAL_NAMESPACE,
1756+
1,
1757+
)
17471758
return cls.from_string(key_str)
17481759
except (ValueError, TypeError) as error:
17491760
raise InvalidKeyError(cls, str(usage_key)) from error

0 commit comments

Comments
 (0)