-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add typing annotations #112
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
* Add typing-extensions * Fix assignment * Add GHA mypy
* `IComparator` is explicitly inherited `* One of the comparators has a different `__init__` function signature so `IComparator` can't be a protocol if it were to represent all the comparators. * Added `ConfigGetValue` and `NameFactory` protocols here which is used by other files.
* ValueToken is an extension of ValueProxy
* Guard circular dependency with `staticconf/config` with `TYPE_CHECKING`. * `ConfigNamespace` and `ValueProxy` refer to each other
Ping @benbariteau @matthewess |
Ping @dnephin. Final commit marks the package as typed. |
sloane-shark
approved these changes
Sep 21, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I already gave this a shipit, my bad!
dnephin
approved these changes
Sep 23, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
This was referenced Oct 7, 2022
Merged
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.
Following mypy output, I typed each file until no errors were left.
Additionally added GHA for
tox -e mypy
to prevent regressions in PRs.Notes
There's a circular type dependency between
config.py
(ConfigNamespace
) andproxy.py
(ValueProxy
) which is guarded byTYPE_CHECKING
.While I don't explicitly test for py3.10,
Protocol
was moved fromtyping-extensions
totyping
so there's a version guard for theProtocol
import.In
statticonfig/loader
, there are manyComparator
s using theIComparator
interface. Normally, I would turnIComparator
into aProtocol
, but one of the classes adds a default keyword arg to__init__
which makes it different. To facilitate typing, I opted to make the inheritance explicit instead.Closes #108