Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Complete typing of connresource #1202

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

Open
DanielNoord wants to merge 1 commit into MagicStack:master
base: master
Choose a base branch
Loading
from DanielNoord:type-connresource

Conversation

Copy link
Contributor

@DanielNoord DanielNoord commented Oct 30, 2024

We can actually enable mypy --strict for this module now :)

Typing decorators correctly is notoriously hard and you need some pretty advanced concepts, but this does the trick. I have checked and both pyright and mypy consider this to be the correct type for all call sites to guarded.
The rest is pretty straightforward. The changes outside of the module are because mypy --strict doesn't allow calls to untyped functions, which I therefore had to fix.


def guarded(meth):
_ConnectionResourceT = TypeVar(
"_ConnectionResourceT", bound="ConnectionResource", contravariant=True
Copy link
Contributor Author

@DanielNoord DanielNoord Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bound needs to be stringified, even with from __future__ import annotations. I checked this locally.

Copy link
Contributor Author

@elprans Same questions here: could you retrigger the CI so this can get merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@elprans elprans elprans approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /