Skip to content

Commit 8528a60

Browse files
committed
Merge branch 'main' of https://github.com/pypa/setuptools into type-check-3.12
2 parents eb26141 + 7aa30d0 commit 8528a60

File tree

117 files changed

+562
-598
lines changed

Some content is hidden

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

117 files changed

+562
-598
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
repos:
2-
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.4.9
4-
hooks:
5-
- id: ruff
6-
- id: ruff-format
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.5.7
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format

_distutils_hack/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# don't import any costly modules
2-
import sys
32
import os
4-
3+
import sys
54

65
report_url = (
76
"https://github.com/pypa/setuptools/issues/new?"

conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import pytest
44

5-
65
pytest_plugins = 'setuptools.tests.fixtures'
76

87

newsfragments/4554.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed ``setputools.sandbox``'s Python 2 ``builtins.file`` support -- by :user:`Avasam`

pkg_resources/__init__.py

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,68 +22,66 @@
2222

2323
from __future__ import annotations
2424

25-
from abc import ABC
2625
import sys
26+
from abc import ABC
2727

2828
if sys.version_info < (3, 8): # noqa: UP036 # Check for unsupported versions
2929
raise RuntimeError("Python 3.8 or later is required")
3030

31-
import os
31+
import _imp
32+
import collections
33+
import email.parser
34+
import errno
35+
import functools
36+
import importlib
37+
import importlib.abc
38+
import importlib.machinery
39+
import inspect
3240
import io
33-
import time
41+
import ntpath
42+
import operator
43+
import os
44+
import pkgutil
45+
import platform
46+
import plistlib
47+
import posixpath
3448
import re
49+
import stat
50+
import tempfile
51+
import textwrap
52+
import time
3553
import types
54+
import warnings
55+
import zipfile
56+
import zipimport
57+
from pkgutil import get_importer
3658
from typing import (
59+
TYPE_CHECKING,
3760
Any,
3861
BinaryIO,
39-
Literal,
62+
Callable,
4063
Dict,
64+
Iterable,
4165
Iterator,
66+
Literal,
4267
Mapping,
4368
MutableSequence,
4469
NamedTuple,
4570
NoReturn,
46-
Tuple,
47-
Union,
48-
TYPE_CHECKING,
4971
Protocol,
50-
Callable,
51-
Iterable,
72+
Tuple,
5273
TypeVar,
74+
Union,
5375
overload,
5476
)
55-
import zipfile
56-
import zipimport
57-
import warnings
58-
import stat
59-
import functools
60-
import pkgutil
61-
import operator
62-
import platform
63-
import collections
64-
import plistlib
65-
import email.parser
66-
import errno
67-
import tempfile
68-
import textwrap
69-
import inspect
70-
import ntpath
71-
import posixpath
72-
import importlib
73-
import importlib.abc
74-
import importlib.machinery
75-
from pkgutil import get_importer
76-
77-
import _imp
7877

7978
sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip
8079
# workaround for #4476
8180
sys.modules.pop('backports', None)
8281

8382
# capture these to bypass sandboxing
84-
from os import utime
85-
from os import open as os_open
86-
from os.path import isdir, split
83+
from os import open as os_open, utime # isort: skip
84+
from os.path import isdir, split # isort: skip
8785

8886
try:
8987
from os import mkdir, rename, unlink
@@ -93,20 +91,16 @@
9391
# no write support, probably under GAE
9492
WRITE_SUPPORT = False
9593

96-
from jaraco.text import (
97-
yield_lines,
98-
drop_comment,
99-
join_continuation,
100-
)
10194
import packaging.markers
10295
import packaging.requirements
10396
import packaging.specifiers
10497
import packaging.utils
10598
import packaging.version
99+
from jaraco.text import drop_comment, join_continuation, yield_lines
106100
from platformdirs import user_cache_dir as _user_cache_dir
107101

108102
if TYPE_CHECKING:
109-
from _typeshed import BytesPath, StrPath, StrOrBytesPath
103+
from _typeshed import BytesPath, StrOrBytesPath, StrPath
110104
from typing_extensions import Self, TypeAlias
111105

112106
warnings.warn(

pkg_resources/tests/test_find_distributions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from pathlib import Path
21
import shutil
2+
from pathlib import Path
3+
34
import pytest
4-
import pkg_resources
55

6+
import pkg_resources
67

78
TESTS_DATA_DIR = Path(__file__).parent / 'data'
89

pkg_resources/tests/test_pkg_resources.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
from __future__ import annotations
22

33
import builtins
4-
import sys
5-
import tempfile
6-
import os
7-
import zipfile
84
import datetime
5+
import os
96
import plistlib
10-
import subprocess
117
import stat
12-
import distutils.dist
13-
import distutils.command.install_egg_info
14-
8+
import subprocess
9+
import sys
10+
import tempfile
11+
import zipfile
1512
from unittest import mock
1613

17-
from pkg_resources import (
18-
DistInfoDistribution,
19-
Distribution,
20-
EggInfoDistribution,
21-
)
22-
2314
import pytest
2415

2516
import pkg_resources
17+
from pkg_resources import DistInfoDistribution, Distribution, EggInfoDistribution
18+
19+
import distutils.command.install_egg_info
20+
import distutils.dist
2621

2722

2823
class EggRemover(str):

pkg_resources/tests/test_resources.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1+
import itertools
12
import os
2-
import sys
3-
import string
43
import platform
5-
import itertools
4+
import string
5+
import sys
66

77
import pytest
88
from packaging.specifiers import SpecifierSet
99

1010
import pkg_resources
1111
from pkg_resources import (
12-
parse_requirements,
13-
VersionConflict,
14-
parse_version,
1512
Distribution,
1613
EntryPoint,
1714
Requirement,
18-
safe_version,
19-
safe_name,
15+
VersionConflict,
2016
WorkingSet,
17+
parse_requirements,
18+
parse_version,
19+
safe_name,
20+
safe_version,
2121
)
2222

2323

@@ -862,8 +862,8 @@ def test_path_order(self, symlinked_tmpdir):
862862
(subpkg / '__init__.py').write_text(vers_str % number, encoding='utf-8')
863863

864864
with pytest.warns(DeprecationWarning, match="pkg_resources.declare_namespace"):
865-
import nspkg.subpkg
866865
import nspkg
866+
import nspkg.subpkg
867867
expected = [str(site.realpath() / 'nspkg') for site in site_dirs]
868868
assert nspkg.__path__ == expected
869869
assert nspkg.subpkg.__version__ == 1

pkg_resources/tests/test_working_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import functools
12
import inspect
23
import re
34
import textwrap
4-
import functools
55

66
import pytest
77

ruff.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extend-select = [
1414
"ANN2", # missing-return-type-*
1515
"FA", # flake8-future-annotations
1616
"F404", # late-future-import
17+
"I", # isort
1718
"PYI", # flake8-pyi
1819
"UP", # pyupgrade
1920
"TRY",
@@ -56,6 +57,16 @@ ignore = [
5657
"setuptools/__init__.py" = ["E402"]
5758
"pkg_resources/__init__.py" = ["E402"]
5859

60+
[lint.isort]
61+
combine-as-imports = true
62+
split-on-trailing-comma = false
63+
# Force Ruff/isort to always import setuptools before distutils in tests as long as distutils_hack is supported
64+
# This also ensures _distutils_hack is imported before distutils
65+
# https://github.com/pypa/setuptools/issues/4137
66+
section-order = ["future", "standard-library", "eager", "third-party", "first-party", "local-folder", "delayed"]
67+
sections.eager = ["_distutils_hack"]
68+
sections.delayed = ["distutils"]
69+
5970
[lint.flake8-annotations]
6071
ignore-fully-untyped = true
6172

0 commit comments

Comments
 (0)