Skip to content

Commit d0e3de1

Browse files
authored
Merge branch 'main' into TRY
2 parents e166477 + 6c224d3 commit d0e3de1

22 files changed

+78
-40
lines changed

.coveragerc

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ disable_warnings =
1212
[report]
1313
show_missing = True
1414
exclude_also =
15-
# jaraco/skeleton#97
16-
@overload
15+
# Exclude common false positives per
16+
# https://coverage.readthedocs.io/en/latest/excluding.html#advanced-exclusion
17+
# Ref jaraco/skeleton#97 and jaraco/skeleton#135
18+
class .*\bProtocol\):
1719
if TYPE_CHECKING:

.pre-commit-config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.1.8
3+
rev: v0.5.6
44
hooks:
55
- id: ruff
6+
args: [--fix, --unsafe-fixes]
67
- id: ruff-format

distutils/_modified.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def missing_as_newer(source):
6363
return missing == 'newer' and not os.path.exists(source)
6464

6565
ignored = os.path.exists if missing == 'ignore' else None
66-
return any(
66+
return not os.path.exists(target) or any(
6767
missing_as_newer(source) or _newer(source, target)
6868
for source in filter(ignored, sources)
6969
)

distutils/archive_util.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ def make_archive(
266266
raise ValueError(f"unknown archive format '{format}'")
267267

268268
func = format_info[0]
269-
for arg, val in format_info[1]:
270-
kwargs[arg] = val
269+
kwargs.update(format_info[1])
271270

272271
if format != 'zip':
273272
kwargs['owner'] = owner

distutils/command/build_ext.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,7 @@ def swig_sources(self, sources, extension):
638638

639639
# Do not override commandline arguments
640640
if not self.swig_opts:
641-
for o in extension.swig_opts:
642-
swig_cmd.append(o)
641+
swig_cmd.extend(extension.swig_opts)
643642

644643
for source in swig_sources:
645644
target = swig_targets[source]

distutils/command/install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def create_home_path(self):
680680
if not self.user:
681681
return
682682
home = convert_path(os.path.expanduser("~"))
683-
for _name, path in self.config_vars.items():
683+
for path in self.config_vars.values():
684684
if str(path).startswith(home) and not os.path.isdir(path):
685685
self.debug_print(f"os.makedirs('{path}', 0o700)")
686686
os.makedirs(path, 0o700)
-217 KB
Binary file not shown.

distutils/command/wininst-10.0.exe

-187 KB
Binary file not shown.
-574 KB
Binary file not shown.

distutils/command/wininst-14.0.exe

-448 KB
Binary file not shown.

distutils/command/wininst-6.0.exe

-60 KB
Binary file not shown.

distutils/command/wininst-7.1.exe

-64 KB
Binary file not shown.

distutils/command/wininst-8.0.exe

-60 KB
Binary file not shown.
-219 KB
Binary file not shown.

distutils/command/wininst-9.0.exe

-192 KB
Binary file not shown.

distutils/cygwinccompiler.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ def link(
172172

173173
# Generate .def file
174174
contents = [f"LIBRARY {os.path.basename(output_filename)}", "EXPORTS"]
175-
for sym in export_symbols:
176-
contents.append(sym)
175+
contents.extend(export_symbols)
177176
self.execute(write_file, (def_file, contents), f"writing {def_file}")
178177

179178
# next add options for def-file

distutils/dist.py

+8-19
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@
1010
import pathlib
1111
import re
1212
import sys
13+
import warnings
1314
from collections.abc import Iterable
1415
from email import message_from_file
1516

16-
from ._vendor.packaging.utils import canonicalize_name, canonicalize_version
17-
18-
try:
19-
import warnings
20-
except ImportError:
21-
warnings = None
22-
2317
from ._log import log
18+
from ._vendor.packaging.utils import canonicalize_name, canonicalize_version
2419
from .debug import DEBUG
2520
from .errors import (
2621
DistutilsArgError,
@@ -249,10 +244,7 @@ def __init__(self, attrs=None): # noqa: C901
249244
attrs['license'] = attrs['licence']
250245
del attrs['licence']
251246
msg = "'licence' distribution option is deprecated; use 'license'"
252-
if warnings is not None:
253-
warnings.warn(msg)
254-
else:
255-
sys.stderr.write(msg + "\n")
247+
warnings.warn(msg)
256248

257249
# Now work on the rest of the attributes. Any attribute that's
258250
# not already defined is invalid!
@@ -354,7 +346,8 @@ def _gen_paths(self):
354346
prefix = '.' * (os.name == 'posix')
355347
filename = prefix + 'pydistutils.cfg'
356348
if self.want_user_cfg:
357-
yield pathlib.Path('~').expanduser() / filename
349+
with contextlib.suppress(RuntimeError):
350+
yield pathlib.Path('~').expanduser() / filename
358351

359352
# All platforms support local setup.cfg
360353
yield pathlib.Path('setup.cfg')
@@ -658,7 +651,7 @@ def _show_help(
658651
)
659652
print()
660653

661-
for command in self.commands:
654+
for command in commands:
662655
if isinstance(command, type) and issubclass(command, Command):
663656
klass = command
664657
else:
@@ -741,9 +734,7 @@ def print_commands(self):
741734
import distutils.command
742735

743736
std_commands = distutils.command.__all__
744-
is_std = set()
745-
for cmd in std_commands:
746-
is_std.add(cmd)
737+
is_std = set(std_commands)
747738

748739
extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
749740

@@ -769,9 +760,7 @@ def get_command_list(self):
769760
import distutils.command
770761

771762
std_commands = distutils.command.__all__
772-
is_std = set()
773-
for cmd in std_commands:
774-
is_std.add(cmd)
763+
is_std = set(std_commands)
775764

776765
extra_commands = [cmd for cmd in self.cmdclass.keys() if cmd not in is_std]
777766

distutils/tests/test_modified.py

+7
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,10 @@ def test_newer_pairwise_group(groups_target):
117117
newer = newer_pairwise_group([groups_target.newer], [groups_target.target])
118118
assert older == ([], [])
119119
assert newer == ([groups_target.newer], [groups_target.target])
120+
121+
122+
def test_newer_group_no_sources_no_target(tmp_path):
123+
"""
124+
Consider no sources and no target "newer".
125+
"""
126+
assert newer_group([], str(tmp_path / 'does-not-exist'))

mypy.ini

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
[mypy]
2-
ignore_missing_imports = True
3-
# required to support namespace packages
4-
# https://github.com/python/mypy/issues/14057
2+
# Is the project well-typed?
3+
strict = False
4+
5+
# Early opt-in even when strict = False
6+
warn_unused_ignores = True
7+
warn_redundant_casts = True
8+
enable_error_code = ignore-without-code
9+
10+
# Support namespace packages per https://github.com/python/mypy/issues/14057
511
explicit_package_bases = True
12+
13+
# Disable overload-overlap due to many false-positives
14+
disable_error_code = overload-overlap

pyproject.toml

+25-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ Source = "https://github.com/pypa/distutils"
2727
test = [
2828
# upstream
2929
"pytest >= 6, != 8.1.*",
30-
"pytest-checkdocs >= 2.4",
31-
"pytest-cov",
32-
"pytest-mypy",
33-
"pytest-enabler >= 2.2",
34-
"pytest-ruff >= 0.2.1; sys_platform != 'cygwin'",
3530

3631
# local
3732
"pytest >= 7.4.3", # 186
@@ -46,6 +41,7 @@ test = [
4641
# workaround for pytest-dev/pytest#12490
4742
"pytest < 8.1; python_version < '3.12'",
4843
]
44+
4945
doc = [
5046
# upstream
5147
"sphinx >= 3.5",
@@ -57,7 +53,30 @@ doc = [
5753
# local
5854
]
5955

56+
check = [
57+
"pytest-checkdocs >= 2.4",
58+
"pytest-ruff >= 0.2.1; sys_platform != 'cygwin'",
59+
]
60+
61+
cover = [
62+
"pytest-cov",
63+
]
64+
65+
enabler = [
66+
"pytest-enabler >= 2.2",
67+
]
68+
69+
type = [
70+
# upstream
71+
"pytest-mypy",
72+
73+
# local
74+
]
75+
76+
6077
[tool.setuptools_scm]
6178

79+
6280
[tool.pytest-enabler.mypy]
63-
# disabled
81+
# Disabled due to jaraco/skeleton#143
82+
# Disabled as distutils isn't ready yet

ruff.toml

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@ extend-select = [
55
"W",
66

77
# local
8+
"B",
9+
"I",
810
"ISC",
11+
"PERF",
912
"RUF010",
1013
"RUF100",
1114
"TRY",
1215
"UP",
1316
]
1417
ignore = [
18+
# local
19+
"PERF203",
1520
"TRY003",
16-
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
21+
22+
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
1723
"W191",
1824
"E111",
1925
"E114",
@@ -28,6 +34,10 @@ ignore = [
2834
"COM819",
2935
"ISC001",
3036
"ISC002",
37+
38+
# local
39+
"B028",
40+
"B904",
3141
]
3242

3343
[format]

tox.ini

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ commands =
1212
usedevelop = True
1313
extras =
1414
test
15+
check
16+
cover
17+
enabler
18+
type
1519

1620
[testenv:diffcov]
1721
description = run tests and check that diff from main is covered

0 commit comments

Comments
 (0)