-
-
Notifications
You must be signed in to change notification settings - Fork 366
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 type annotations #603
Add type annotations #603
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #603 +/- ##
==========================================
- Coverage 98.92% 89.98% -8.94%
==========================================
Files 6 6
Lines 743 869 +126
==========================================
+ Hits 735 782 +47
- Misses 8 87 +79 ☔ View full report in Codecov by Sentry. |
e0bda54
to
87dfa2e
Compare
a80bea3
to
98aa1ac
Compare
08a02e4
to
d0b821a
Compare
402da6c
to
cd2fcde
Compare
4ee284d
to
aaa645b
Compare
@mthuurne time to merge this and release it as beta? |
Ah sorry, I've been pretty busy lately organizing a conference (shameless plug: T-DOSE) and this escaped my attention. I agree that doing a beta is a good idea. However, please let me do one more pass, to at least remove the "WIP:" prefixes from the commit messages. |
Sure @mthuurne, take your time :) |
8fe4407
to
0b5eec7
Compare
0b5eec7
to
16555a7
Compare
We can call the inherited public method using `super()` instead of calling the private method directly.
The `Choices` constructor actually only accepts lists and tuples, not arbitrary sequences. However, using `list` in the annotation opens a can of worms related to type variance.
This allows using the latest annotation syntax supported by the type checker regardless of the runtime Python version.
These annotations are sufficient to pass mypy inspection if mypy is configured to allow unannotated functions.
This required a bit of refactoring to get the type of `STATUS` correct for each suite. There are two cases which I decided not to support in the type system: - passing a list instead of a tuple when defining an option group - `in` checks using a data type that doesn't match the choices
We also type check the unit tests and the unit tests now import functionality from pytest.
The `JoinManager` class is deprecated and not annotated.
I can't find a way to inform mypy of the actual types without duplicating a lot of test code.
This preserves the type of the wrapped descriptor (usually a field). Maybe this is overkill, as `DescriptorWrapper` seems to only be used as part of the `FieldTracker` implementation and is not documented and barely tested. But technically, it is public API.
16555a7
to
5fc37eb
Compare
In particular, `if TYPE_CHECKING:` blocks and `...` in bodies of overloaded method definitions.
I updated the coverage configuration to exclude lines that are only processed by mypy from the coverage measurement. However, rate limiting prevented the coverage upload from being accepted, so the shown coverage stats don't reflect the latest state. |
Actually, it's a bit weird that a project with as little activity as this one is running into rate limiting. Is it possible that the token we're using is old and doesn't specify that this is an open source project rather than a private evaluation? |
If the rate limiting is an issue we should open an dedicated issue to track it. I don't have the permissions to access the settings so I cannot be of any help. Final confirmation: ready for merge? |
Yes, it's ready. The last change should make the coverage numbers more realistic by excluding lines that aren't expected to execute, but it doesn't change any functionality. So even if the change isn't correct, it won't negatively affect a preview release. |
@mthuurne thanks for all the effort you have put into this! Great job! |
This implements the bulk of the changes required for #558. The annotations are still a bit rough, but they have reached a stage where testing with third party code would be useful.