-
-
Notifications
You must be signed in to change notification settings - Fork 393
Enable pyupgrade rule #2809
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
Enable pyupgrade rule #2809
Changes from 6 commits
4af786b
c6a32f2
fab4a08
c31e0a6
bccd2ed
5cbcb46
6891b40
2ce22e7
3e74044
e275513
32c4037
dc1153e
641fa56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ | |
| Callable, | ||
| Iterator, | ||
| Literal, | ||
| Optional, | ||
| TypeVar, | ||
| cast, | ||
| ) | ||
|
|
@@ -245,9 +244,9 @@ class CKeys(enum.IntEnum): | |
| # operation and start a new one. | ||
| @attr.s(slots=True, eq=False) | ||
| class AFDWaiters: | ||
| read_task: Optional[_core.Task] = attr.ib(default=None) | ||
| write_task: Optional[_core.Task] = attr.ib(default=None) | ||
| current_op: Optional[AFDPollOp] = attr.ib(default=None) | ||
| read_task: _core.Task | None = attr.ib(default=None) | ||
| write_task: _core.Task | None = attr.ib(default=None) | ||
| current_op: AFDPollOp | None = attr.ib(default=None) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eh, same as above. I won't make any more comments about 3.9+ features sneaking in.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are going to require runtime typing, on 3.8, and that disallowing using |
||
|
|
||
|
|
||
| # We also need to bundle up all the info for a single op into a standalone | ||
|
|
@@ -585,9 +584,9 @@ def process_events(self, received: EventResult) -> None: | |
| pass | ||
| else: | ||
| exc = _core.TrioInternalError( | ||
| "Failed to cancel overlapped I/O in {} and didn't " | ||
| f"Failed to cancel overlapped I/O in {waiter.name} and didn't " | ||
| "receive the completion either. Did you forget to " | ||
| "call register_with_iocp()?".format(waiter.name) | ||
| "call register_with_iocp()?" | ||
| ) | ||
| # Raising this out of handle_io ensures that | ||
| # the user will see our message even if some | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -841,10 +841,7 @@ def __init__(self, endpoint: DTLSEndpoint, peer_address: Any, ctx: Context): | |
| # support and isn't useful anyway -- especially for DTLS where it's equivalent | ||
| # to just performing a new handshake. | ||
| ctx.set_options( | ||
| ( | ||
| SSL.OP_NO_QUERY_MTU | ||
| | SSL.OP_NO_RENEGOTIATION # type: ignore[attr-defined] | ||
| ) | ||
| SSL.OP_NO_QUERY_MTU | SSL.OP_NO_RENEGOTIATION # type: ignore[attr-defined] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, why did ruff change this? I think it was intentionally formatted to showcase which specific attribute wasn't defined.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw this and the diff and was a bit confused myself, not sure about this one.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another one of my PRs hit this and I looked into it further, this change was by black, not ruff. |
||
| ) | ||
| self._ssl = SSL.Connection(ctx) | ||
| self._handshake_mtu = 0 | ||
|
|
||
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.
Isn't
defaultdicta 3.9+ thing? Why is ruff doing this? Cause thefrom __future__ import annotations? or is this a bug.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.
It’s probably that yes. There’s an option to decide whether to preserve the hints making sense at runtime.
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.
Yes, it decides what's allowed based on both the version you specify and if a future annotations import exists.
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.
There is a setting to make sure runtime typing works, mostly so a specific library can work properly, but in my opinion I agree with ruff's behavior here. Why have outdated versions of the type annotations if we don't have to worry about runtime type annotations?
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.
It's been waffled about a lot in various PR's, without a central decision actually getting taken: #2687
IMHO if we want runtime typing we should have tests for it, and enforce it with linter rules.