Skip to content

Commit

Permalink
Make requested changes, improve type annotation and simplify asDict.
Browse files Browse the repository at this point in the history
  • Loading branch information
knutnergaard committed Dec 3, 2024
1 parent 536be6f commit 7dee4fd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Lib/fontParts/base/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Iterator,
List,
Optional,
Tuple,
)
from collections.abc import MutableMapping

Expand Down Expand Up @@ -198,10 +197,7 @@ def asDict(self) -> Dict[str, LibValueType]:
>>> font.lib.asDict()
"""
d = {}
for k, v in self.items():
d[k] = v
return d
return dict(self)

# -------------------
# Inherited Functions
Expand Down Expand Up @@ -263,6 +259,8 @@ def __iter__(self) -> Iterator[str]:
The iteration order is not fixed.
:return: An :class:`Iterator` over the :class:`str` keys.
Example::
>>> for key in font.lib:
Expand Down Expand Up @@ -343,8 +341,8 @@ def get(self, key: str, default: Optional[LibValueType] = None) -> LibValueType:
"""
return super(BaseLib, self).get(key, default)

def items(self) -> BaseItems[Tuple[str, LibValueType]]:
"""View the lib's items.
def items(self) -> BaseItems[str, LibValueType]:
"""Return the lib's items.
Each item is represented as a :class:`tuple` of key-value pairs, where:
- `key` is a :class:`str`.
Expand All @@ -362,7 +360,7 @@ def items(self) -> BaseItems[Tuple[str, LibValueType]]:
return super(BaseLib, self).items()

def keys(self) -> BaseKeys[str]:
"""view the lib's keys.
"""Return the lib's keys.
:return: A :ref:`type-view` of :class:`str` items representing the lib's keys.
Expand All @@ -376,7 +374,7 @@ def keys(self) -> BaseKeys[str]:
return super(BaseLib, self).keys()

def values(self) -> BaseValues[LibValueType]:
"""View the lib's values.
"""Return the lib's values.
:return: A :ref:`type-view` of :ref:`type-lib-value <lib values>`.
Expand Down

0 comments on commit 7dee4fd

Please sign in to comment.