-
Notifications
You must be signed in to change notification settings - Fork 19
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
Type-checking and mark package as typed #27
Conversation
Hi! |
It is work in progress, so no need to merge now. I would also highly suggest reviewing the changes to ensure they all make sense to you, why a change had to be made, and to ensure I respected the intent of certain logic. For example, when a What is / Why type-checking? Static type checking is about evaluating which type your variables should have at any given point. As well as classes and method signatures etc. It is not a linter (like Flake8, pylint, pycodestyle, etc.) or a formatter (like autopep8, isort, Black, pycln, etc.) # Very simple examples
a = 0
a.lower() # Errors at runtime. Type checkers will catch this.
b: str
b = 0 # type checkers won't accept this
c: str | int
c = 0 # This is fine
c = "" # This is fine What are the tools mentioned? https://google.github.io/pytype/ is a very simple and minimal checker by google that only runs on linux. What are stubs? (PEP 561). And typeshed? Type stubs are
Libraries have the option to mark their packages as "typed" using the Why these changes?
How to type-check locally? On VSCode: On PyCharm: As a command line:
Pyright:
|
f4fda84
to
77e3903
Compare
I still need to add NamedTuples to |
Added `py.typed` marker Added CI action to validate against mypy and pyright Fix type issues for basic typing
Woooow!!! Sorry for making you write that awesome explanation. I'm merging the PR right now! I will have to test everything before uploading it to PyPi. Thanks a LOT!!!! |
Mark pywinctl as typed using the
py.typed
marker. See https://peps.python.org/pep-0561/This allows static type checkers like pyright, mypy, pytype, pycharm, etc. to use inline types instead of looking for a non-existent type-stub.
I've added Github actions to validate typing using pyright and mypy.
Checking all python versions may be overkill. Testing only the oldest supported may be enough.
CI validation: Avasam#1
And finally I've fixed any typing issue from basic type-checking.