-
Notifications
You must be signed in to change notification settings - Fork 146
style: enable py3.10 linting rules #1449
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
base: master
Are you sure you want to change the base?
style: enable py3.10 linting rules #1449
Conversation
|
Partially blocked by python/cpython#140348, though we can revert those aspects. |
d08aff0 to
1ebea09
Compare
|
We should probably revert a portion of d602ba0 with regards to Union | str not working on 3.14 as it currently stands. |
Alternatively, we could stringify those unions. |
| MessageableChannel: TypeAlias = GuildMessageable | DMChannel | GroupChannel | PartialMessageable | ||
| # include non-messageable channels, e.g. category/forum | ||
| AnyChannel = Union[MessageableChannel, AnyGuildChannel] | ||
| AnyChannel: TypeAlias = MessageableChannel | AnyGuildChannel |
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.
Is there a reason to explicitly use TypeAlias for unions like this?
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.
ruff doesn't detect they're unions and therefore doesn't autofix them :^)
| @@ -1,5 +1,6 @@ | |||
| # SPDX-License-Identifier: MIT | |||
|
|
|||
|
|
|||
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.
| @@ -1,5 +1,6 @@ | |||
| # SPDX-License-Identifier: MIT | |||
|
|
|||
|
|
|||
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.
| @@ -1,3 +1,4 @@ | |||
| # SPDX-License-Identifier: MIT | |||
|
|
|||
|
|
|||
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.
| ("int | float", Union[int, float], True), # noqa: UP007 | ||
| ("int | float", int | float, True), |
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.
| ("int | float", Union[int, float], True), # noqa: UP007 | |
| ("int | float", int | float, True), | |
| ("int | float", int | float, True), |
Since this one is testing the 3.10 union syntax, I think it's the only one where we don't necessarily need both test cases
| @pytest.mark.parametrize( | ||
| "typehint", | ||
| [ | ||
| Union[int, str], # noqa: UP007 | ||
| int | str, | ||
| ], | ||
| ) | ||
| def test_forwardref_local(self, typehint) -> None: | ||
| IntOrStr = typehint |
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.
| @pytest.mark.parametrize( | |
| "typehint", | |
| [ | |
| Union[int, str], # noqa: UP007 | |
| int | str, | |
| ], | |
| ) | |
| def test_forwardref_local(self, typehint) -> None: | |
| IntOrStr = typehint | |
| def test_forwardref_local(self) -> None: | |
| IntOrStr = int | str |
The point of this test isn't unions, it was more of a means to an end; we can simply use the new syntax here.
| @pytest.mark.parametrize( | ||
| "typehint", | ||
| [ | ||
| Union[int, str], # noqa: UP007 | ||
| int | str, | ||
| ], | ||
| ) | ||
| def test_forwardref_mixed(self, typehint) -> None: | ||
| LocalIntOrStr = typehint |
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.
same here:
| @pytest.mark.parametrize( | |
| "typehint", | |
| [ | |
| Union[int, str], # noqa: UP007 | |
| int | str, | |
| ], | |
| ) | |
| def test_forwardref_mixed(self, typehint) -> None: | |
| LocalIntOrStr = typehint | |
| def test_forwardref_mixed(self) -> None: | |
| LocalIntOrStr = int | str |
Summary
Checklist
uv run nox -s lintuv run nox -s pyright