Skip to content

Commit d03a581

Browse files
Enable Ruff rule RUF036 (#16477)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ff1d18c commit d03a581

67 files changed

Lines changed: 163 additions & 164 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ ignore = [
197197
"PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
198198
# Often just leads to redundant more verbose code when needing an actual str
199199
"PTH208", # Use `pathlib.Path.iterdir()` instead.
200-
"RUF036", # `None` is not at the end of the union
201200
# Allow FIXME
202201
"TD001", # Invalid TODO tag: `{tag}`
203202
# Git blame is sufficient

‎stdlib/_interpreters.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_config(id: SupportsIndex, *, restrict: bool = False) -> types.SimpleName
3333
def whence(id: SupportsIndex) -> _Whence: ...
3434
def exec(
3535
id: SupportsIndex, code: str | types.CodeType | Callable[[], object], shared: _SharedDict = {}, *, restrict: bool = False
36-
) -> None | types.SimpleNamespace: ...
36+
) -> types.SimpleNamespace | None: ...
3737
def call(
3838
id: SupportsIndex,
3939
callable: Callable[..., _R],

‎stdlib/_ssl.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class _SSLContext:
7979
post_handshake_auth: bool
8080
protocol: int
8181
security_level: int
82-
sni_callback: Callable[[SSLObject, str, SSLContext], None | int] | None
82+
sni_callback: Callable[[SSLObject, str, SSLContext], int | None] | None
8383
verify_flags: int
8484
verify_mode: int
8585
def __new__(cls, protocol: int, /) -> Self: ...

‎stdlib/ast.pyi‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ if sys.version_info >= (3, 14):
11071107
**kwargs: Unpack[_Attributes],
11081108
) -> Self: ...
11091109

1110-
_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType
1110+
_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | EllipsisType | None
11111111

11121112
class Constant(expr):
11131113
__match_args__ = ("value", "kind")
@@ -1741,7 +1741,7 @@ if sys.version_info >= (3, 15):
17411741
mode: Literal["exec", "eval", "func_type", "single"] = "exec",
17421742
*,
17431743
type_comments: bool = False,
1744-
feature_version: None | int | tuple[int, int] = None,
1744+
feature_version: int | tuple[int, int] | None = None,
17451745
optimize: Literal[-1, 0, 1, 2] = -1,
17461746
module: str | None = None,
17471747
) -> _T: ...
@@ -1752,7 +1752,7 @@ if sys.version_info >= (3, 15):
17521752
mode: Literal["exec"] = "exec",
17531753
*,
17541754
type_comments: bool = False,
1755-
feature_version: None | int | tuple[int, int] = None,
1755+
feature_version: int | tuple[int, int] | None = None,
17561756
optimize: Literal[-1, 0, 1, 2] = -1,
17571757
module: str | None = None,
17581758
) -> Module: ...
@@ -1763,7 +1763,7 @@ if sys.version_info >= (3, 15):
17631763
mode: Literal["eval"],
17641764
*,
17651765
type_comments: bool = False,
1766-
feature_version: None | int | tuple[int, int] = None,
1766+
feature_version: int | tuple[int, int] | None = None,
17671767
optimize: Literal[-1, 0, 1, 2] = -1,
17681768
module: str | None = None,
17691769
) -> Expression: ...
@@ -1774,7 +1774,7 @@ if sys.version_info >= (3, 15):
17741774
mode: Literal["func_type"],
17751775
*,
17761776
type_comments: bool = False,
1777-
feature_version: None | int | tuple[int, int] = None,
1777+
feature_version: int | tuple[int, int] | None = None,
17781778
optimize: Literal[-1, 0, 1, 2] = -1,
17791779
module: str | None = None,
17801780
) -> FunctionType: ...
@@ -1785,7 +1785,7 @@ if sys.version_info >= (3, 15):
17851785
mode: Literal["single"],
17861786
*,
17871787
type_comments: bool = False,
1788-
feature_version: None | int | tuple[int, int] = None,
1788+
feature_version: int | tuple[int, int] | None = None,
17891789
optimize: Literal[-1, 0, 1, 2] = -1,
17901790
module: str | None = None,
17911791
) -> Interactive: ...
@@ -1795,7 +1795,7 @@ if sys.version_info >= (3, 15):
17951795
*,
17961796
mode: Literal["eval"],
17971797
type_comments: bool = False,
1798-
feature_version: None | int | tuple[int, int] = None,
1798+
feature_version: int | tuple[int, int] | None = None,
17991799
optimize: Literal[-1, 0, 1, 2] = -1,
18001800
module: str | None = None,
18011801
) -> Expression: ...
@@ -1805,7 +1805,7 @@ if sys.version_info >= (3, 15):
18051805
*,
18061806
mode: Literal["func_type"],
18071807
type_comments: bool = False,
1808-
feature_version: None | int | tuple[int, int] = None,
1808+
feature_version: int | tuple[int, int] | None = None,
18091809
optimize: Literal[-1, 0, 1, 2] = -1,
18101810
module: str | None = None,
18111811
) -> FunctionType: ...
@@ -1815,7 +1815,7 @@ if sys.version_info >= (3, 15):
18151815
*,
18161816
mode: Literal["single"],
18171817
type_comments: bool = False,
1818-
feature_version: None | int | tuple[int, int] = None,
1818+
feature_version: int | tuple[int, int] | None = None,
18191819
optimize: Literal[-1, 0, 1, 2] = -1,
18201820
module: str | None = None,
18211821
) -> Interactive: ...
@@ -1826,7 +1826,7 @@ if sys.version_info >= (3, 15):
18261826
mode: str = "exec",
18271827
*,
18281828
type_comments: bool = False,
1829-
feature_version: None | int | tuple[int, int] = None,
1829+
feature_version: int | tuple[int, int] | None = None,
18301830
optimize: Literal[-1, 0, 1, 2] = -1,
18311831
module: str | None = None,
18321832
) -> mod: ...
@@ -1838,7 +1838,7 @@ elif sys.version_info >= (3, 13):
18381838
mode: Literal["exec", "eval", "func_type", "single"] = "exec",
18391839
*,
18401840
type_comments: bool = False,
1841-
feature_version: None | int | tuple[int, int] = None,
1841+
feature_version: int | tuple[int, int] | None = None,
18421842
optimize: Literal[-1, 0, 1, 2] = -1,
18431843
) -> _T: ...
18441844
@overload
@@ -1848,7 +1848,7 @@ elif sys.version_info >= (3, 13):
18481848
mode: Literal["exec"] = "exec",
18491849
*,
18501850
type_comments: bool = False,
1851-
feature_version: None | int | tuple[int, int] = None,
1851+
feature_version: int | tuple[int, int] | None = None,
18521852
optimize: Literal[-1, 0, 1, 2] = -1,
18531853
) -> Module: ...
18541854
@overload
@@ -1858,7 +1858,7 @@ elif sys.version_info >= (3, 13):
18581858
mode: Literal["eval"],
18591859
*,
18601860
type_comments: bool = False,
1861-
feature_version: None | int | tuple[int, int] = None,
1861+
feature_version: int | tuple[int, int] | None = None,
18621862
optimize: Literal[-1, 0, 1, 2] = -1,
18631863
) -> Expression: ...
18641864
@overload
@@ -1868,7 +1868,7 @@ elif sys.version_info >= (3, 13):
18681868
mode: Literal["func_type"],
18691869
*,
18701870
type_comments: bool = False,
1871-
feature_version: None | int | tuple[int, int] = None,
1871+
feature_version: int | tuple[int, int] | None = None,
18721872
optimize: Literal[-1, 0, 1, 2] = -1,
18731873
) -> FunctionType: ...
18741874
@overload
@@ -1878,7 +1878,7 @@ elif sys.version_info >= (3, 13):
18781878
mode: Literal["single"],
18791879
*,
18801880
type_comments: bool = False,
1881-
feature_version: None | int | tuple[int, int] = None,
1881+
feature_version: int | tuple[int, int] | None = None,
18821882
optimize: Literal[-1, 0, 1, 2] = -1,
18831883
) -> Interactive: ...
18841884
@overload
@@ -1887,7 +1887,7 @@ elif sys.version_info >= (3, 13):
18871887
*,
18881888
mode: Literal["eval"],
18891889
type_comments: bool = False,
1890-
feature_version: None | int | tuple[int, int] = None,
1890+
feature_version: int | tuple[int, int] | None = None,
18911891
optimize: Literal[-1, 0, 1, 2] = -1,
18921892
) -> Expression: ...
18931893
@overload
@@ -1896,7 +1896,7 @@ elif sys.version_info >= (3, 13):
18961896
*,
18971897
mode: Literal["func_type"],
18981898
type_comments: bool = False,
1899-
feature_version: None | int | tuple[int, int] = None,
1899+
feature_version: int | tuple[int, int] | None = None,
19001900
optimize: Literal[-1, 0, 1, 2] = -1,
19011901
) -> FunctionType: ...
19021902
@overload
@@ -1905,7 +1905,7 @@ elif sys.version_info >= (3, 13):
19051905
*,
19061906
mode: Literal["single"],
19071907
type_comments: bool = False,
1908-
feature_version: None | int | tuple[int, int] = None,
1908+
feature_version: int | tuple[int, int] | None = None,
19091909
optimize: Literal[-1, 0, 1, 2] = -1,
19101910
) -> Interactive: ...
19111911
@overload
@@ -1915,7 +1915,7 @@ elif sys.version_info >= (3, 13):
19151915
mode: str = "exec",
19161916
*,
19171917
type_comments: bool = False,
1918-
feature_version: None | int | tuple[int, int] = None,
1918+
feature_version: int | tuple[int, int] | None = None,
19191919
optimize: Literal[-1, 0, 1, 2] = -1,
19201920
) -> mod: ...
19211921
else:
@@ -1926,7 +1926,7 @@ else:
19261926
mode: Literal["exec", "eval", "func_type", "single"] = "exec",
19271927
*,
19281928
type_comments: bool = False,
1929-
feature_version: None | int | tuple[int, int] = None,
1929+
feature_version: int | tuple[int, int] | None = None,
19301930
) -> _T: ...
19311931
@overload
19321932
def parse(
@@ -1935,7 +1935,7 @@ else:
19351935
mode: Literal["exec"] = "exec",
19361936
*,
19371937
type_comments: bool = False,
1938-
feature_version: None | int | tuple[int, int] = None,
1938+
feature_version: int | tuple[int, int] | None = None,
19391939
) -> Module: ...
19401940
@overload
19411941
def parse(
@@ -1944,7 +1944,7 @@ else:
19441944
mode: Literal["eval"],
19451945
*,
19461946
type_comments: bool = False,
1947-
feature_version: None | int | tuple[int, int] = None,
1947+
feature_version: int | tuple[int, int] | None = None,
19481948
) -> Expression: ...
19491949
@overload
19501950
def parse(
@@ -1953,7 +1953,7 @@ else:
19531953
mode: Literal["func_type"],
19541954
*,
19551955
type_comments: bool = False,
1956-
feature_version: None | int | tuple[int, int] = None,
1956+
feature_version: int | tuple[int, int] | None = None,
19571957
) -> FunctionType: ...
19581958
@overload
19591959
def parse(
@@ -1962,31 +1962,31 @@ else:
19621962
mode: Literal["single"],
19631963
*,
19641964
type_comments: bool = False,
1965-
feature_version: None | int | tuple[int, int] = None,
1965+
feature_version: int | tuple[int, int] | None = None,
19661966
) -> Interactive: ...
19671967
@overload
19681968
def parse(
19691969
source: str | ReadableBuffer,
19701970
*,
19711971
mode: Literal["eval"],
19721972
type_comments: bool = False,
1973-
feature_version: None | int | tuple[int, int] = None,
1973+
feature_version: int | tuple[int, int] | None = None,
19741974
) -> Expression: ...
19751975
@overload
19761976
def parse(
19771977
source: str | ReadableBuffer,
19781978
*,
19791979
mode: Literal["func_type"],
19801980
type_comments: bool = False,
1981-
feature_version: None | int | tuple[int, int] = None,
1981+
feature_version: int | tuple[int, int] | None = None,
19821982
) -> FunctionType: ...
19831983
@overload
19841984
def parse(
19851985
source: str | ReadableBuffer,
19861986
*,
19871987
mode: Literal["single"],
19881988
type_comments: bool = False,
1989-
feature_version: None | int | tuple[int, int] = None,
1989+
feature_version: int | tuple[int, int] | None = None,
19901990
) -> Interactive: ...
19911991
@overload
19921992
def parse(
@@ -1995,7 +1995,7 @@ else:
19951995
mode: str = "exec",
19961996
*,
19971997
type_comments: bool = False,
1998-
feature_version: None | int | tuple[int, int] = None,
1998+
feature_version: int | tuple[int, int] | None = None,
19991999
) -> mod: ...
20002000

20012001
def literal_eval(node_or_string: str | AST) -> Any: ...

‎stdlib/asyncio/base_events.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
2323
_Context: TypeAlias = dict[str, Any]
2424
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object]
2525
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
26-
_SSLContext: TypeAlias = bool | None | ssl.SSLContext
26+
_SSLContext: TypeAlias = bool | ssl.SSLContext | None
2727

2828
class Server(AbstractServer):
2929
if sys.version_info >= (3, 11):

‎stdlib/asyncio/events.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ _ProtocolT = TypeVar("_ProtocolT", bound=BaseProtocol)
6666
_Context: TypeAlias = dict[str, Any]
6767
_ExceptionHandler: TypeAlias = Callable[[AbstractEventLoop, _Context], object]
6868
_ProtocolFactory: TypeAlias = Callable[[], BaseProtocol]
69-
_SSLContext: TypeAlias = bool | None | ssl.SSLContext
69+
_SSLContext: TypeAlias = bool | ssl.SSLContext | None
7070

7171
@type_check_only
7272
class _TaskFactory(Protocol):

‎stdlib/asyncio/subprocess.pyi‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ if sys.version_info >= (3, 11):
6161
restore_signals: bool = True,
6262
start_new_session: bool = False,
6363
pass_fds: Collection[int] = (),
64-
group: None | str | int = None,
65-
extra_groups: None | Collection[str | int] = None,
66-
user: None | str | int = None,
64+
group: str | int | None = None,
65+
extra_groups: Collection[str | int] | None = None,
66+
user: str | int | None = None,
6767
umask: int = -1,
6868
process_group: int | None = None,
6969
pipesize: int = -1,
@@ -93,9 +93,9 @@ if sys.version_info >= (3, 11):
9393
restore_signals: bool = True,
9494
start_new_session: bool = False,
9595
pass_fds: Collection[int] = (),
96-
group: None | str | int = None,
97-
extra_groups: None | Collection[str | int] = None,
98-
user: None | str | int = None,
96+
group: str | int | None = None,
97+
extra_groups: Collection[str | int] | None = None,
98+
user: str | int | None = None,
9999
umask: int = -1,
100100
process_group: int | None = None,
101101
pipesize: int = -1,
@@ -127,9 +127,9 @@ else:
127127
restore_signals: bool = True,
128128
start_new_session: bool = False,
129129
pass_fds: Collection[int] = (),
130-
group: None | str | int = None,
131-
extra_groups: None | Collection[str | int] = None,
132-
user: None | str | int = None,
130+
group: str | int | None = None,
131+
extra_groups: Collection[str | int] | None = None,
132+
user: str | int | None = None,
133133
umask: int = -1,
134134
pipesize: int = -1,
135135
) -> Process: ...
@@ -158,9 +158,9 @@ else:
158158
restore_signals: bool = True,
159159
start_new_session: bool = False,
160160
pass_fds: Collection[int] = (),
161-
group: None | str | int = None,
162-
extra_groups: None | Collection[str | int] = None,
163-
user: None | str | int = None,
161+
group: str | int | None = None,
162+
extra_groups: Collection[str | int] | None = None,
163+
user: str | int | None = None,
164164
umask: int = -1,
165165
pipesize: int = -1,
166166
) -> Process: ...

‎stdlib/cgi.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class FieldStorage:
8181
length: int
8282
done: int
8383
list: _list[Any] | None
84-
value: None | bytes | _list[Any]
84+
value: bytes | _list[Any] | None
8585
def __init__(
8686
self,
8787
fp: IO[Any] | None = None,

0 commit comments

Comments
 (0)