Skip to content

Commit

Permalink
Start fixing type annotations for 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mlenzen committed Aug 17, 2019
1 parent f8d9cf5 commit 8a09195
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions collections_extended/_util.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Sentinel(object):
Inspired by https://pypi.org/project/sentinels/ Inspired by https://pypi.org/project/sentinels/
""" """


_registry: Dict = {} _registry = {} # type: Dict[str, Sentinel]


def __new__(cls, name: str): def __new__(cls, name: str):
"""Find the Sentinel object with name or create a new one.""" """Find the Sentinel object with name or create a new one."""
Expand All @@ -48,7 +48,7 @@ def __new__(cls, name: str):


def __init__(self, name: str): def __init__(self, name: str):
super(Sentinel, self).__init__() super(Sentinel, self).__init__()
self.name: str = name self.name = name # type: str


def __repr__(self): def __repr__(self):
return '<%s>' % self.name return '<%s>' % self.name
Expand Down
6 changes: 3 additions & 3 deletions collections_extended/bags.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def __init__(self, iterable: Iterable[Hashable] = None):
This runs in O(len(iterable)) This runs in O(len(iterable))
""" """
self._dict: Dict[Hashable, int] = dict() self._dict = dict() # type: Dict[Hashable, int]
self._size: int = 0 self._size = 0 # type: int
if iterable: if iterable:
if isinstance(iterable, _basebag): if isinstance(iterable, _basebag):
# iterable: _basebag # iterable: _basebag
Expand Down Expand Up @@ -508,7 +508,7 @@ def product(self, other: Iterable[Hashable], operator: Callable = None):
other_bag = other other_bag = other
else: else:
other_bag = self._from_iterable(other) other_bag = self._from_iterable(other)
values: Dict[Hashable, int] = defaultdict(int) values = defaultdict(int) # type: Dict[Hashable, int]
for elem, count in self.counts(): for elem, count in self.counts():
for other_elem, other_count in other_bag.counts(): for other_elem, other_count in other_bag.counts():
if operator: if operator:
Expand Down
4 changes: 2 additions & 2 deletions collections_extended/bijection.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def __init__(
Iterable[Tuple[Hashable, Hashable]], Iterable[Tuple[Hashable, Hashable]],
None, None,
] = None, ] = None,
**kwargs: Hashable, **kwargs: Hashable
): ):
"""Create a bijection from an iterable. """Create a bijection from an iterable.
Matches dict.__init__. Matches dict.__init__.
""" """
self._data: Dict[Hashable, Hashable] = {} self._data = {} # type: Dict[Hashable, Hashable]
self.__inverse = self.__new__(bijection) self.__inverse = self.__new__(bijection)
self.__inverse._data = {} self.__inverse._data = {}
self.__inverse.__inverse = self self.__inverse.__inverse = self
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def long_description():
], ],
long_description=long_description(), long_description=long_description(),
long_description_content_type='text/x-rst', long_description_content_type='text/x-rst',
install_requires=['setuptools'], install_requires=['setuptools', 'typing'],
tests_require=['pytest'], tests_require=['pytest'],
package_data={'': ['README.rst', 'LICENSE', 'CONTRIBUTING.rst']}, package_data={'': ['README.rst', 'LICENSE', 'CONTRIBUTING.rst']},
cmdclass={'test': PyTest}, cmdclass={'test': PyTest},
Expand Down

0 comments on commit 8a09195

Please sign in to comment.