Skip to content

Commit 832c850

Browse files
authored
Automatic updates from Ruff for Python 3.9+ (#4721)
2 parents 544cf20 + e8a62df commit 832c850

18 files changed

+44
-61
lines changed

pkg_resources/__init__.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,17 @@
5050
import warnings
5151
import zipfile
5252
import zipimport
53+
from collections.abc import Iterable, Iterator, Mapping, MutableSequence
5354
from pkgutil import get_importer
5455
from typing import (
5556
TYPE_CHECKING,
5657
Any,
5758
BinaryIO,
5859
Callable,
59-
Dict,
60-
Iterable,
61-
Iterator,
6260
Literal,
63-
Mapping,
64-
MutableSequence,
6561
NamedTuple,
6662
NoReturn,
6763
Protocol,
68-
Tuple,
6964
TypeVar,
7065
Union,
7166
overload,
@@ -424,7 +419,7 @@ def get_provider(moduleOrReq: str | Requirement) -> IResourceProvider | Distribu
424419
return _find_adapter(_provider_factories, loader)(module)
425420

426421

427-
@functools.lru_cache(maxsize=None)
422+
@functools.cache
428423
def _macos_vers():
429424
version = platform.mac_ver()[0]
430425
# fallback for MacPorts
@@ -1120,7 +1115,7 @@ def __setstate__(self, e_k_b_n_c) -> None:
11201115
self.callbacks = callbacks[:]
11211116

11221117

1123-
class _ReqExtras(Dict["Requirement", Tuple[str, ...]]):
1118+
class _ReqExtras(dict["Requirement", tuple[str, ...]]):
11241119
"""
11251120
Map each requirement to the extras that demanded it.
11261121
"""
@@ -1952,7 +1947,7 @@ def __init__(self) -> None:
19521947
empty_provider = EmptyProvider()
19531948

19541949

1955-
class ZipManifests(Dict[str, "MemoizedZipManifests.manifest_mod"]):
1950+
class ZipManifests(dict[str, "MemoizedZipManifests.manifest_mod"]):
19561951
"""
19571952
zip manifest builder
19581953
"""
@@ -2662,7 +2657,7 @@ def _normalize_cached(filename: StrOrBytesPath) -> str | bytes: ...
26622657

26632658
else:
26642659

2665-
@functools.lru_cache(maxsize=None)
2660+
@functools.cache
26662661
def _normalize_cached(filename):
26672662
return normalize_path(filename)
26682663

setuptools/_reqs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import annotations
22

3+
from collections.abc import Iterable, Iterator
34
from functools import lru_cache
4-
from typing import TYPE_CHECKING, Callable, Iterable, Iterator, TypeVar, Union, overload
5+
from typing import TYPE_CHECKING, Callable, TypeVar, Union, overload
56

67
import jaraco.text as text
78
from packaging.requirements import Requirement

setuptools/build_meta.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
import tempfile
3838
import tokenize
3939
import warnings
40+
from collections.abc import Iterable, Iterator, Mapping
4041
from pathlib import Path
41-
from typing import TYPE_CHECKING, Iterable, Iterator, List, Mapping, Union
42+
from typing import TYPE_CHECKING, Union
4243

4344
import setuptools
4445

@@ -146,7 +147,7 @@ def suppress_known_deprecation():
146147
yield
147148

148149

149-
_ConfigSettings: TypeAlias = Union[Mapping[str, Union[str, List[str], None]], None]
150+
_ConfigSettings: TypeAlias = Union[Mapping[str, Union[str, list[str], None]], None]
150151
"""
151152
Currently the user can run::
152153

setuptools/command/_requirestxt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
import io
1313
from collections import defaultdict
14+
from collections.abc import Mapping
1415
from itertools import filterfalse
15-
from typing import Dict, Mapping, TypeVar
16+
from typing import TypeVar
1617

1718
from jaraco.text import yield_lines
1819
from packaging.requirements import Requirement
@@ -22,7 +23,7 @@
2223

2324
# dict can work as an ordered set
2425
_T = TypeVar("_T")
25-
_Ordered = Dict[_T, None]
26+
_Ordered = dict[_T, None]
2627

2728

2829
def _prepare(

setuptools/command/bdist_wheel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
import sys
1515
import sysconfig
1616
import warnings
17+
from collections.abc import Iterable, Sequence
1718
from email.generator import BytesGenerator, Generator
1819
from email.policy import EmailPolicy
1920
from glob import iglob
2021
from shutil import rmtree
21-
from typing import TYPE_CHECKING, Callable, Iterable, Literal, Sequence, cast
22+
from typing import TYPE_CHECKING, Callable, Literal, cast
2223
from zipfile import ZIP_DEFLATED, ZIP_STORED
2324

2425
from packaging import tags, version as _packaging_version

setuptools/command/build_ext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import itertools
44
import os
55
import sys
6+
from collections.abc import Iterator
67
from importlib.machinery import EXTENSION_SUFFIXES
78
from importlib.util import cache_from_source as _compiled_file_name
89
from pathlib import Path
9-
from typing import TYPE_CHECKING, Iterator
10+
from typing import TYPE_CHECKING
1011

1112
from setuptools.dist import Distribution
1213
from setuptools.errors import BaseError

setuptools/command/build_py.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import os
66
import stat
77
import textwrap
8+
from collections.abc import Iterable, Iterator
89
from functools import partial
910
from glob import glob
1011
from pathlib import Path
11-
from typing import Iterable, Iterator
1212

1313
from more_itertools import unique_everseen
1414

setuptools/command/editable_wheel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
import os
1818
import shutil
1919
import traceback
20+
from collections.abc import Iterable, Iterator, Mapping
2021
from contextlib import suppress
2122
from enum import Enum
2223
from inspect import cleandoc
2324
from itertools import chain, starmap
2425
from pathlib import Path
2526
from tempfile import TemporaryDirectory
2627
from types import TracebackType
27-
from typing import TYPE_CHECKING, Iterable, Iterator, Mapping, Protocol, TypeVar, cast
28+
from typing import TYPE_CHECKING, Protocol, TypeVar, cast
2829

2930
from .. import Command, _normalization, _path, errors, namespaces
3031
from .._path import StrPath

setuptools/config/_apply_pyprojecttoml.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
import logging
1414
import os
15+
from collections.abc import Mapping
1516
from email.headerregistry import Address
1617
from functools import partial, reduce
1718
from inspect import cleandoc
1819
from itertools import chain
1920
from types import MappingProxyType
20-
from typing import TYPE_CHECKING, Any, Callable, Dict, Mapping, TypeVar, Union
21+
from typing import TYPE_CHECKING, Any, Callable, TypeVar, Union
2122

2223
from .._path import StrPath
2324
from ..errors import RemovedConfigError
@@ -34,7 +35,7 @@
3435

3536

3637
EMPTY: Mapping = MappingProxyType({}) # Immutable dict-like
37-
_ProjectReadmeValue: TypeAlias = Union[str, Dict[str, str]]
38+
_ProjectReadmeValue: TypeAlias = Union[str, dict[str, str]]
3839
_Correspondence: TypeAlias = Callable[["Distribution", Any, Union[StrPath, None]], None]
3940
_T = TypeVar("_T")
4041

setuptools/config/expand.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
import os
2626
import pathlib
2727
import sys
28+
from collections.abc import Iterable, Iterator, Mapping
2829
from configparser import ConfigParser
2930
from glob import iglob
3031
from importlib.machinery import ModuleSpec, all_suffixes
3132
from itertools import chain
3233
from pathlib import Path
3334
from types import ModuleType, TracebackType
34-
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Mapping, TypeVar
35+
from typing import TYPE_CHECKING, Any, Callable, TypeVar
3536

3637
from .._path import StrPath, same_path as _same_path
3738
from ..discovery import find_package_path

0 commit comments

Comments
 (0)