Open
Conversation
fdbd2d8 to
3a4679d
Compare
This adds an initial [tool.mypy] section to pyproject.toml which checks modules which have no typing errors. We set python_version = "3.7" to ensure we are always checking against the syntax and stdlib of our lowest supported Python version. This also adds mypy to requirements.txt for development.
This also updates the single() implementation, replacing the use of _SENTINEL as a nothing-to-return marker with a separate bool variable. Note that we need to use both collections.abc.Iterable (for isinstance()) and typing.Iterable (for type annotation) until Python 3.9 (#265). If we attempt to use the former for type annotation in Python < 3.9, we get the following error: TypeError: 'ABCMeta' object is not subscriptable This also simplifies coerce_sequence() to always return a list, removing the return-type argument.
This updates git_describe() to return Optional[GitDescribe] to simplify typing. The whole file looks much closer now to this (and in some ways better): https://github.com/JonathonReinhart/scuba/blob/18135bb19a/scuba/version.py This also adds importlib-metadata to requirements.txt for development. This is because even though we're running with Python 3.11 on Debian 12, we specify python_version = "3.8" in pyproject.toml, which means the backport is needed for type checking.
For some reason, running mypy v1.8.0 --python-version=3.8 in a Python 3.11 venv doesn't pick up the importlib_resources types, even when the (runtime-unnecessary) importlib-resources package is installed, so we have to add a cast.
Also take the opportunity to clean up some wildcard imports.
One slightly annoying issue is that I like to set attributes to None in close() after they've been closed. But this requires marking their types as Optional, which requires checking that they are not None where they are used. A well-polished API would check and raise a "closed" exception. For now, we just assert. This also fixes #278.
3a4679d to
97ca99d
Compare
We also add types-pyinstaller to requirements.txt.
97ca99d to
35d08c5
Compare
|
Any idea when we might get this PR? I think this might fix my "Invalid ELF image: Magic number does not match" issue. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.