typing overhaul + pre-commit updates #200
Draft
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.
STILL WIP!!!
For a bit of a background, Im planning to go off the list of open typing issues and fix stuff. First one in the list was some BLE-related one, and when i cloned it and started working, noticed that
mypy
wasn't ignoring this (adafruit_ble
) module due to the lack ofpy.typed
on it. Then decided to open a quick PR to simply add such empty marker file... But, surprise, typing was very broken, so here we are, fixing it ;)Notes
optional-requirements.txt
circuitpython-stubs
to run the testsassert
on some places to concreteUnion
andOptional
down to one of their options.assert foo is not None
before doingfoo.bar
on the very next line.py.typed
will be added on the final commit, when every single file passes the checksWhile working on this, i've made a couple upgrades to
pre-commit
's configisort
pylint
(old version does not build/install on Py312)mypy
Right now, only a couple errors are left. These, for some reason, are not spotted when running
pre-commit run --all-files
but i get them running$ mypy adafruit_ble
manually. Would like to know what the cause for this is, maybe related to pre-commit using its own virtual environment....