Skip to content

Commit

Permalink
Merge pull request #4787 from Avasam/simplify-typed-assignements
Browse files Browse the repository at this point in the history
Simplified typed assignments
  • Loading branch information
jaraco authored Jan 5, 2025
2 parents 86d8c99 + 3acab2c commit 50b15db
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setuptools/command/_requirestxt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/editable_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion setuptools/config/pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setuptools/config/setupcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
4 changes: 2 additions & 2 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 50b15db

Please sign in to comment.