-
Notifications
You must be signed in to change notification settings - Fork 15
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
Run mypy for full repo & fix all mypy issues #227
Merged
Merged
Conversation
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
Easier to work with the function when using mypy
Needed for == operation with StrEnum members
The __eq__ and __hash__ were not required after all.
in other platforms than linux
there is probably no real use case for that and not supporting None makes the type annotations of the function easier
The 'self' refers to a class so perhaps clearer the the variable name is 'cls'
was: ConstantEnumMeta (previously, StrEnum was called Constant)
There was old information.
no need to.
* these parts are unreachable, and that is known. Just testing that they're really are unreachable
Use module level Counter instead of function-level attribute dict
(disallow being None)
using typing-extensions
Less places where we have to check for python version, and less places where a custom '# pragma: ' is required
- Added new rules: no-cover-if-py-gte-38 and no-cover-if-py-lt-38
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.
Mypy
Previously, mypy was only ran for
./wakepy
folder. But there seems some added value in running static type checking also for tests, since it also shows how different parts of wakepy look like when running mypy on a project that uses wakepy. I found at least places which were not so user friendly for people using wakepy, and fixed them. I also fixed 80+ mypy errors.StrEnums and their values
Each subclass of StrEnum has not corresponding Values class. For example PlatformName has PlatformNameValues which is a typing.Literal. This is to allow giving the literal values (strings) as function arguments, when a function expects value listed in StrEnum. The StrEnum and the corresponding Values are enforced to be in sync with a unit test.
StrEnum class is now simplified a bit.
do_assert
added a do_assert helper for tests which can be used in place of assert statement if you're getting [unreachable] errors with mypy.
Other
Mode.activation_result is now ActivationResult (was: ActivationResult | None). This makes it easier to work with the object when using wakepy and mypy in a project.
Method.name is now always a string. Unnamed methods have special name "unnamed". This makes working with wakepy+mypy easier. There is also now Method._is_unnamed() which can be used to check if the Method has a name.