Skip to content

Commit b88d0a1

Browse files
authored
Sync with typeshed post-#4504 (#4719)
2 parents 0f6055c + 1183377 commit b88d0a1

File tree

8 files changed

+21
-15
lines changed

8 files changed

+21
-15
lines changed

setuptools/command/bdist_egg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def get_ext_outputs(self):
322322
return all_outputs, ext_outputs
323323

324324

325-
NATIVE_EXTENSIONS = dict.fromkeys('.dll .so .dylib .pyd'.split())
325+
NATIVE_EXTENSIONS: dict[str, None] = dict.fromkeys('.dll .so .dylib .pyd'.split())
326326

327327

328328
def walk_egg(egg_dir):

setuptools/command/editable_wheel.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from itertools import chain, starmap
2424
from pathlib import Path
2525
from tempfile import TemporaryDirectory
26+
from types import TracebackType
2627
from typing import TYPE_CHECKING, Iterable, Iterator, Mapping, Protocol, TypeVar, cast
2728

2829
from .. import Command, _normalization, _path, errors, namespaces
@@ -379,13 +380,13 @@ def _select_strategy(
379380
class EditableStrategy(Protocol):
380381
def __call__(
381382
self, wheel: WheelFile, files: list[str], mapping: Mapping[str, str]
382-
): ...
383+
) -> object: ...
383384
def __enter__(self) -> Self: ...
384385
def __exit__(
385386
self,
386-
_exc_type: object,
387-
_exc_value: object,
388-
_traceback: object,
387+
_exc_type: type[BaseException] | None,
388+
_exc_value: BaseException | None,
389+
_traceback: TracebackType | None,
389390
) -> object: ...
390391

391392

setuptools/command/rotate.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import shutil
5+
from typing import ClassVar
56

67
from setuptools import Command
78

@@ -20,7 +21,7 @@ class rotate(Command):
2021
('keep=', 'k', "number of matching distributions to keep"),
2122
]
2223

23-
boolean_options: list[str] = []
24+
boolean_options: ClassVar[list[str]] = []
2425

2526
def initialize_options(self):
2627
self.match = None

setuptools/config/expand.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ def canonic_data_files(
354354
]
355355

356356

357-
def entry_points(text: str, text_source: str = "entry-points") -> dict[str, dict]:
357+
def entry_points(
358+
text: str, text_source: str = "entry-points"
359+
) -> dict[str, dict[str, str]]:
358360
"""Given the contents of entry-points file,
359361
process it into a 2-level dictionary (``dict[str, dict[str, str]]``).
360362
The first level keys are entry-point groups, the second level keys are

setuptools/config/pyprojecttoml.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def _obtain_readme(self, dist: Distribution) -> dict[str, str] | None:
330330

331331
def _obtain_entry_points(
332332
self, dist: Distribution, package_dir: Mapping[str, str]
333-
) -> dict[str, dict] | None:
333+
) -> dict[str, dict[str, Any]] | None:
334334
fields = ("entry-points", "scripts", "gui-scripts")
335335
if not any(field in self.dynamic for field in fields):
336336
return None
@@ -340,7 +340,8 @@ def _obtain_entry_points(
340340
return None
341341

342342
groups = _expand.entry_points(text)
343-
expanded = {"entry-points": groups}
343+
# Any is str | dict[str, str], but causes variance issues
344+
expanded: dict[str, dict[str, Any]] = {"entry-points": groups}
344345

345346
def _set_scripts(field: str, group: str):
346347
if group in groups:

setuptools/config/setupcfg.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
TYPE_CHECKING,
2121
Any,
2222
Callable,
23+
ClassVar,
2324
Dict,
2425
Generic,
2526
Iterable,
@@ -245,7 +246,7 @@ class ConfigHandler(Generic[Target]):
245246
246247
"""
247248

248-
aliases: dict[str, str] = {}
249+
aliases: ClassVar[dict[str, str]] = {}
249250
"""Options aliases.
250251
For compatibility with various packages. E.g.: d2to1 and pbr.
251252
Note: `-` in keys is replaced with `_` by config parser.

setuptools/discovery.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from fnmatch import fnmatchcase
4646
from glob import glob
4747
from pathlib import Path
48-
from typing import TYPE_CHECKING, Iterable, Mapping
48+
from typing import TYPE_CHECKING, ClassVar, Iterable, Mapping
4949

5050
import _distutils_hack.override # noqa: F401
5151

@@ -84,8 +84,8 @@ def __contains__(self, item: str) -> bool:
8484
class _Finder:
8585
"""Base class that exposes functionality for module/package finders"""
8686

87-
ALWAYS_EXCLUDE: tuple[str, ...] = ()
88-
DEFAULT_EXCLUDE: tuple[str, ...] = ()
87+
ALWAYS_EXCLUDE: ClassVar[tuple[str, ...]] = ()
88+
DEFAULT_EXCLUDE: ClassVar[tuple[str, ...]] = ()
8989

9090
@classmethod
9191
def find(

setuptools/sandbox.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import tempfile
1313
import textwrap
1414
from types import TracebackType
15-
from typing import TYPE_CHECKING
15+
from typing import TYPE_CHECKING, ClassVar
1616

1717
import pkg_resources
1818
from pkg_resources import working_set
@@ -416,7 +416,7 @@ def _remap_pair(self, operation, src, dst, *args, **kw):
416416
class DirectorySandbox(AbstractSandbox):
417417
"""Restrict operations to a single subdirectory - pseudo-chroot"""
418418

419-
write_ops: dict[str, None] = dict.fromkeys([
419+
write_ops: ClassVar[dict[str, None]] = dict.fromkeys([
420420
"open",
421421
"chmod",
422422
"chown",

0 commit comments

Comments
 (0)