Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/pypa/setuptools into pkg_re…
Browse files Browse the repository at this point in the history
…sources-type-global-variables
  • Loading branch information
Avasam committed May 9, 2024
2 parents acaa310 + 6d4902a commit faa9f75
Show file tree
Hide file tree
Showing 29 changed files with 387 additions and 5,483 deletions.
14 changes: 9 additions & 5 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ exclude = (?x)(
# *.extern modules that actually live in *._vendor will also cause attr-defined issues on import
disable_error_code = attr-defined

# - pkg_resources tests create modules that won't exists statically before the test is run.
# Let's ignore all "import-not-found" since, if an import really wasn't found, then the test would fail.
[mypy-pkg_resources.tests.*]
disable_error_code = import-not-found

# - Avoid raising issues when importing from "extern" modules, as those are added to path dynamically.
# https://github.com/pypa/setuptools/pull/3979#discussion_r1367968993
# - distutils._modified has different errors on Python 3.8 [import-untyped], on Python 3.9+ [import-not-found]
Expand All @@ -29,8 +34,7 @@ disable_error_code = attr-defined
[mypy-pkg_resources.extern.*,setuptools.extern.*,distutils._modified,jaraco.*,trove_classifiers]
ignore_missing_imports = True

# - pkg_resources tests create modules that won't exists statically before the test is run.
# Let's ignore all "import-not-found" since, if an import really wasn't found, then the test would fail.
# - setuptools._vendor.packaging._manylinux: Mypy issue, this vendored module is already excluded!
[mypy-pkg_resources.tests.*,setuptools._vendor.packaging._manylinux,setuptools.config._validate_pyproject.*]
disable_error_code = import-not-found
# Even when excluding vendored/generated modules, there might be problems: https://github.com/python/mypy/issues/11936#issuecomment-1466764006
[mypy-setuptools._vendor.packaging._manylinux,setuptools.config._validate_pyproject.*]
follow_imports = silent
# silent => ignore errors when following imports
1 change: 1 addition & 0 deletions newsfragments/4324.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed ``typing_extensions`` from vendored dependencies -- by :user:`Avasam`
24 changes: 13 additions & 11 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
Dict,
Iterable,
Optional,
TypeVar,
)
import zipfile
import zipimport
Expand Down Expand Up @@ -97,6 +98,8 @@
stacklevel=2,
)

T = TypeVar("T")


_PEP440_FALLBACK = re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I)

Expand All @@ -111,11 +114,12 @@ class PEP440Warning(RuntimeWarning):
parse_version = packaging.version.Version


_state_vars: Dict[str, Any] = {}
_state_vars: Dict[str, str] = {}


def _declare_state(vartype: str, **kw: object) -> None:
_state_vars.update(dict.fromkeys(kw, vartype))
def _declare_state(vartype: str, varname: str, initial_value: T) -> T:
_state_vars[varname] = vartype
return initial_value


def __getstate__():
Expand Down Expand Up @@ -2017,8 +2021,7 @@ def __init__(self, importer):

_distribution_finders: Dict[
type, Callable[[object, str, bool], Iterable["Distribution"]]
] = {}
_declare_state('dict', _distribution_finders=_distribution_finders)
] = _declare_state('dict', '_distribution_finders', {})


def register_finder(importer_type, distribution_finder):
Expand Down Expand Up @@ -2193,10 +2196,10 @@ def resolve_egg_link(path):

_namespace_handlers: Dict[
type, Callable[[object, str, str, types.ModuleType], Optional[str]]
] = {}
_declare_state('dict', _namespace_handlers=_namespace_handlers)
_namespace_packages: Dict[Optional[str], List[str]] = {}
_declare_state('dict', _namespace_packages=_namespace_packages)
] = _declare_state('dict', '_namespace_handlers', {})
_namespace_packages: Dict[Optional[str], List[str]] = _declare_state(
'dict', '_namespace_packages', {}
)


def register_namespace_handler(importer_type, namespace_handler):
Expand Down Expand Up @@ -3295,8 +3298,7 @@ def _initialize_master_working_set():
Invocation by other packages is unsupported and done
at their own risk.
"""
working_set = WorkingSet._build_master()
_declare_state('object', working_set=working_set)
working_set = _declare_state('object', 'working_set', WorkingSet._build_master())

require = working_set.require
iter_entry_points = working_set.iter_entry_points
Expand Down

This file was deleted.

254 changes: 0 additions & 254 deletions pkg_resources/_vendor/typing_extensions-4.4.0.dist-info/LICENSE

This file was deleted.

Loading

0 comments on commit faa9f75

Please sign in to comment.