Skip to content
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

Replace plugin.args_invariant_decorator_callback with use of ParamSpec #92

Merged
merged 4 commits into from
Dec 1, 2023

Conversation

oremanj
Copy link
Member

@oremanj oremanj commented Dec 1, 2023

Resolves #90, a regression that appeared with mypy 1.7. In order to have ParamSpec available, we now require at least mypy 1.0. args_invariant_decorator_callback is modeled off the mypy contextlib plugin which was replaced with use of ParamSpec in Oct 2022 (python/mypy@3108669); mypy 1.0 came out in Feb 2023.

The test described in #90 no longer fails now that this hook has been removed.

While we're here, update stubs to be consistent with Trio's new inline stubs to satisfy CI. This included:

  • giving names to the statistics types
  • making some SocketType attributes into properties
  • listing out the arguments of __aexit__ instead of using a star-args shortcut
  • fixing the signature of SocketStream.setsockopt

@oremanj oremanj mentioned this pull request Dec 1, 2023
@oremanj oremanj force-pushed the support-mypy17 branch 3 times, most recently from 7fa3498 to 8db07b5 Compare December 1, 2023 01:29
Copy link
Member

@CoolCat467 CoolCat467 left a comment

Choose a reason for hiding this comment

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

This looks good on a surface level, but I haven't checked that these match with the real project.

@oremanj
Copy link
Member Author

oremanj commented Dec 1, 2023

I solemnly swear that all of the statistics classes were copy-pasted from current trio. :-) stubtest is happy so I think there's relatively little that could be incorrect.

Copy link

@A5rocks A5rocks left a comment

Choose a reason for hiding this comment

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

Beyond these issues, looks fine.

(but I may have missed something)

trio-stubs/__init__.pyi Outdated Show resolved Hide resolved
class _IOStatistics:
tasks_waiting: int = attr.ib()
monitors: int = attr.ib()
backend: Literal["kqueue"] = attr.ib(init=False, default="kqueue")
Copy link

Choose a reason for hiding this comment

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

I don't think init=False or default matters for these but tbh probably fine to keep

Copy link
Member Author

Choose a reason for hiding this comment

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

init= impacts the signature of the generated __init__ which stubtest will notice mismatches in

@oremanj oremanj merged commit 2404a3b into python-trio:master Dec 1, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

trio_typing.plugin incompatible with mypy 1.7's new type inference
3 participants