Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support mypy typing The big change here is to convert the library from a "single file module" to a "packages" module. Here there is only only one package and we use an __init__.py with `from .multiset import *` to continue to allow `from multiset import Multiset` and similar. As crazy as it sounds I don't think there's any way to signal to mypy with the py.typed file that the library has type stubs without restructuring like this. I also made some small changes to multiset.pyi to bring it in line with what mypy wants. A wheel package built with `python -m build` or `python -m build --wheel` will now create a directory under site-packages containing multiset.py, multiset.pyi, and py.typed, rather than just putting multiset.py into site-packages as it did previously. If we publish this on pypi, clients of the library will be able to use it typed without `type: ignore` comments and will be able to type their Multisets like this and catch more bugs as well as not getting told off by mypy: ``` from multiset import Multiset m = Multiset[int | float] = Multiset([1, 2.2, 9, 33.8]) m1.add("hello") # mypy says 'Argument 1 to "add" of "Multiset" has incompatible type "str"; expected "int | float"' ``` Cool! * Update Makefiles with new location of code --------- Co-authored-by: Manuel Krebber <admin@wheerd.de>
- Loading branch information
Showing
8 changed files
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .multiset import * |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters