Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mypy typing #127

Merged
merged 3 commits into from Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -2,7 +2,7 @@ init:
pip install -r dev-requirements.txt

test:
py.test tests/ --doctest-modules multiset.py README.rst
py.test tests/ --doctest-modules multiset/multiset.py README.rst

check:
pylint multiset
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Expand Up @@ -4,3 +4,5 @@ coverage>=6.3,<8
setuptools_scm>=7.0,<9.0
tox>=2.5,<4.0
pytest-cov>=4.0,<5.0
mypy>=1.9,<2
build>=1.2,<2
wheerd marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion make.bat
Expand Up @@ -11,7 +11,7 @@ goto :eof
goto :eof

:test
py.test tests\ --doctest-modules multiset.py README.rst
py.test tests\ --doctest-modules multiset/multiset.py README.rst
goto :eof

:check
Expand Down
1 change: 1 addition & 0 deletions multiset/__init__.py
@@ -0,0 +1 @@
from .multiset import *
File renamed without changes.
9 changes: 9 additions & 0 deletions multiset.pyi → multiset/multiset.pyi
Expand Up @@ -2,6 +2,8 @@
from typing import (Generic, ItemsView, Iterable, Iterator, KeysView, Mapping, Hashable,
MutableMapping, Optional, Set, Type, TypeVar, Union, ValuesView, overload)

from _typeshed import SupportsKeysAndGetItem
wheerd marked this conversation as resolved.
Show resolved Hide resolved

T = TypeVar('T')
TElement = TypeVar('TElement', bound=Hashable)
OtherType = Union[Iterable[TElement], Mapping[TElement, int]]
Expand Down Expand Up @@ -84,7 +86,14 @@ class BaseMultiset(Mapping[TElement, int], Generic[TElement]):
class Multiset(BaseMultiset[TElement], MutableMapping[TElement, int], Generic[TElement]):
def __setitem__(self, element: TElement, multiplicity: int) -> None: ...
def __delitem__(self, element: TElement) -> None: ...
@overload
def update(self, *others: OtherType) -> None: ...
@overload
def update(self, __m: SupportsKeysAndGetItem[T, int], /, **kwargs: int) -> None: ...
wheerd marked this conversation as resolved.
Show resolved Hide resolved
@overload
def update(self, __m: Iterable[tuple[T, int]], /, **kwargs: int) -> None: ...
@overload
def update(self, **kwargs: int) -> None: ...
def union_update(self, *others: OtherType) -> None: ...
@overload
def __ior__(self: Self, other: Set[TElement]) -> Self: ...
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -29,7 +29,7 @@ setup_requires =
setuptools >= 46
setuptools_scm
python_requires = >= 3.8
py_modules = multiset
packages = multiset
test_suite = tests

[options.package_data]
Expand Down