Skip to content
Permalink
Browse files

Start fixing type annotations for 3.5

  • Loading branch information...
mlenzen committed Aug 17, 2019
1 parent f8d9cf5 commit 8a091958559d8cde468b82f96391d4690422bc83
Showing with 8 additions and 8 deletions.
  1. +2 −2 collections_extended/_util.py
  2. +3 −3 collections_extended/bags.py
  3. +2 −2 collections_extended/bijection.py
  4. +1 −1 setup.py
@@ -35,7 +35,7 @@ class Sentinel(object):
Inspired by https://pypi.org/project/sentinels/
"""

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

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

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

def __repr__(self):
return '<%s>' % self.name
@@ -102,8 +102,8 @@ def __init__(self, iterable: Iterable[Hashable] = None):
This runs in O(len(iterable))
"""
self._dict: Dict[Hashable, int] = dict()
self._size: int = 0
self._dict = dict() # type: Dict[Hashable, int]
self._size = 0 # type: int
if iterable:
if isinstance(iterable, _basebag):
# iterable: _basebag
@@ -508,7 +508,7 @@ def product(self, other: Iterable[Hashable], operator: Callable = None):
other_bag = other
else:
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 other_elem, other_count in other_bag.counts():
if operator:
@@ -18,13 +18,13 @@ def __init__(
Iterable[Tuple[Hashable, Hashable]],
None,
] = None,
**kwargs: Hashable,
**kwargs: Hashable
):
"""Create a bijection from an iterable.
Matches dict.__init__.
"""
self._data: Dict[Hashable, Hashable] = {}
self._data = {} # type: Dict[Hashable, Hashable]
self.__inverse = self.__new__(bijection)
self.__inverse._data = {}
self.__inverse.__inverse = self
@@ -67,7 +67,7 @@ def long_description():
],
long_description=long_description(),
long_description_content_type='text/x-rst',
install_requires=['setuptools'],
install_requires=['setuptools', 'typing'],
tests_require=['pytest'],
package_data={'': ['README.rst', 'LICENSE', 'CONTRIBUTING.rst']},
cmdclass={'test': PyTest},

0 comments on commit 8a09195

Please sign in to comment.
You can’t perform that action at this time.