diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 87cfa75218..68feeb0593 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -873,9 +873,7 @@ def resolve( # Mapping of requirement to set of distributions that required it; # useful for reporting info about conflicts. - required_by: collections.defaultdict[Requirement, set[str]] = ( - collections.defaultdict(set) - ) + required_by = collections.defaultdict[Requirement, set[str]](set) while requirements: # process dependencies breadth-first diff --git a/setuptools/command/_requirestxt.py b/setuptools/command/_requirestxt.py index 171f41b87e..9029b12514 100644 --- a/setuptools/command/_requirestxt.py +++ b/setuptools/command/_requirestxt.py @@ -38,13 +38,13 @@ def _prepare( def _convert_extras_requirements( extras_require: Mapping[str, _StrOrIter], -) -> Mapping[str, _Ordered[Requirement]]: +) -> defaultdict[str, _Ordered[Requirement]]: """ Convert requirements in `extras_require` of the form `"extra": ["barbazquux; {marker}"]` to `"extra:{marker}": ["barbazquux"]`. """ - output: Mapping[str, _Ordered[Requirement]] = defaultdict(dict) + output = defaultdict[str, _Ordered[Requirement]](dict) for section, v in extras_require.items(): # Do not strip empty sections. output[section] diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index 994b4b4167..d9e1eb974f 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -498,7 +498,7 @@ def license_paths(self) -> Iterable[str]: # Setuptools has resolved any patterns to actual file names return self.distribution.metadata.license_files or () - files: set[str] = set() + files = set[str]() metadata = self.distribution.get_option_dict("metadata") if setuptools_major_version >= 42: # Setuptools recognizes the license_files option but does not do globbing diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index 6d23d11fad..b03e677757 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -506,7 +506,7 @@ def template_vars(self) -> tuple[str, str, dict[str, str], dict[str, list[str]]] package_dir = self.dist.package_dir or {} roots = _find_package_roots(top_level, package_dir, src_root) - namespaces_: dict[str, list[str]] = dict( + namespaces_ = dict( chain( _find_namespaces(self.dist.packages or [], roots), ((ns, []) for ns in _find_virtual_namespaces(roots)), diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index 15b0baa18e..fd6c5968c8 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -185,7 +185,7 @@ def __init__( self.dynamic_cfg = self.setuptools_cfg.get("dynamic", {}) self.ignore_option_errors = ignore_option_errors self._dist = dist - self._referenced_files: set[str] = set() + self._referenced_files = set[str]() def _ensure_dist(self) -> Distribution: from setuptools.dist import Distribution diff --git a/setuptools/config/setupcfg.py b/setuptools/config/setupcfg.py index f2eb833b22..4615815b6b 100644 --- a/setuptools/config/setupcfg.py +++ b/setuptools/config/setupcfg.py @@ -253,7 +253,7 @@ def __init__( self.sections = dict(self._section_options(options)) self.set_options: list[str] = [] self.ensure_discovered = ensure_discovered - self._referenced_files: set[str] = set() + self._referenced_files = set[str]() """After parsing configurations, this property will enumerate all files referenced by the "file:" directive. Private API for setuptools only. """ diff --git a/setuptools/dist.py b/setuptools/dist.py index ba45504aa8..f878b2fa45 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -320,7 +320,7 @@ def __init__(self, attrs: MutableMapping[str, Any] | None = None) -> None: # Private API (setuptools-use only, not restricted to Distribution) # Stores files that are referenced by the configuration and need to be in the # sdist (e.g. `version = file: VERSION.txt`) - self._referenced_files: set[str] = set() + self._referenced_files = set[str]() self.set_defaults = ConfigDiscovery(self) @@ -399,7 +399,7 @@ def _normalize_requires(self): def _finalize_license_files(self) -> None: """Compute names of all license files which should be included.""" license_files: list[str] | None = self.metadata.license_files - patterns: list[str] = license_files if license_files else [] + patterns = license_files or [] license_file: str | None = self.metadata.license_file if license_file and license_file not in patterns: