From c1f2daa56dc3baf206bf78886fb34d8dd70d4dc7 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 22 Feb 2025 13:34:19 +0000 Subject: [PATCH 1/4] Fix TODO comments and typos --- pkg_resources/__init__.py | 3 --- setuptools/_static.py | 2 +- setuptools/_vendor/autocommand/autoparse.py | 2 +- setuptools/_vendor/packaging/metadata.py | 8 ++++---- setuptools/command/editable_wheel.py | 6 +++--- setuptools/command/install.py | 2 +- setuptools/tests/test_build_py.py | 2 +- setuptools/unicode_utils.py | 2 +- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 68feeb0593..86caf45177 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -3326,9 +3326,6 @@ def has_version(self) -> bool: except ValueError: issue_warning("Unbuilt egg for " + repr(self)) return False - except SystemError: - # TODO: remove this except clause when python/cpython#103632 is fixed. - return False return True def clone(self, **kw: str | int | IResourceProvider | None) -> Self: diff --git a/setuptools/_static.py b/setuptools/_static.py index 075a0bcddf..af35862cf8 100644 --- a/setuptools/_static.py +++ b/setuptools/_static.py @@ -27,7 +27,7 @@ class Static: def _prevent_modification(target: type, method: str, copying: str) -> None: """ Because setuptools is very flexible we cannot fully prevent - plugins and user customisations from modifying static values that were + plugins and user customizations from modifying static values that were parsed from config files. But we can attempt to block "in-place" mutations and identify when they were done. diff --git a/setuptools/_vendor/autocommand/autoparse.py b/setuptools/_vendor/autocommand/autoparse.py index 0276a3fae1..3ed80ed8a4 100644 --- a/setuptools/_vendor/autocommand/autoparse.py +++ b/setuptools/_vendor/autocommand/autoparse.py @@ -137,7 +137,7 @@ def _add_arguments(param, parser, used_char_args, add_nos): arg_spec['type'] = str # TODO: special case for list type. - # - How to specificy type of list members? + # - How to specify type of list members? # - param: [int] # - param: int =[] # - action='append' vs nargs='*' diff --git a/setuptools/_vendor/packaging/metadata.py b/setuptools/_vendor/packaging/metadata.py index 721f411cfc..7bbfee156d 100644 --- a/setuptools/_vendor/packaging/metadata.py +++ b/setuptools/_vendor/packaging/metadata.py @@ -193,10 +193,10 @@ def _parse_project_urls(data: list[str]) -> dict[str, str]: # be the missing value, then they'd have multiple '' values that # overwrite each other in a accumulating dict. # - # The other potentional issue is that it's possible to have the + # The other potential issue is that it's possible to have the # same label multiple times in the metadata, with no solid "right" # answer with what to do in that case. As such, we'll do the only - # thing we can, which is treat the field as unparseable and add it + # thing we can, which is treat the field as unparsable and add it # to our list of unparsed fields. parts = [p.strip() for p in pair.split(",", 1)] parts.extend([""] * (max(0, 2 - len(parts)))) # Ensure 2 items @@ -209,8 +209,8 @@ def _parse_project_urls(data: list[str]) -> dict[str, str]: label, url = parts if label in urls: # The label already exists in our set of urls, so this field - # is unparseable, and we can just add the whole thing to our - # unparseable data and stop processing it. + # is unparsable, and we can just add the whole thing to our + # unparsable data and stop processing it. raise KeyError("duplicate labels in project urls") urls[label] = url diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index b03e677757..1a544ec258 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -278,7 +278,7 @@ def _run_build_subcommands(self) -> None: This method implements a temporary workaround to support the ecosystem while the implementations catch up. """ - # TODO: Once plugins/customisations had the chance to catch up, replace + # TODO: Once plugins/customizations had the chance to catch up, replace # `self._run_build_subcommands()` with `self.run_command("build")`. # Also remove _safely_run, TestCustomBuildPy. Suggested date: Aug/2023. build = self.get_finalized_command("build") @@ -309,7 +309,7 @@ def _safely_run(self, cmd_name: str): https://setuptools.pypa.io/en/latest/userguide/extension.html. For the time being `setuptools` will silence this error and ignore - the faulty command, but this behaviour will change in future versions. + the faulty command, but this behavior will change in future versions. """, # TODO: define due_date # There is a series of shortcomings with the available editable install @@ -564,7 +564,7 @@ def _encode_pth(content: str) -> bytes: .pth files are always read with 'locale' encoding, the recommendation from the cpython core developers is to write them as ``open(path, "w")`` and ignore warnings (see python/cpython#77102, pypa/setuptools#3937). - This function tries to simulate this behaviour without having to create an + This function tries to simulate this behavior without having to create an actual file, in a way that supports a range of active Python versions. (There seems to be some variety in the way different version of Python handle ``encoding=None``, not all of them use ``locale.getpreferredencoding(False)`` diff --git a/setuptools/command/install.py b/setuptools/command/install.py index 741b140c70..15ef364688 100644 --- a/setuptools/command/install.py +++ b/setuptools/command/install.py @@ -68,7 +68,7 @@ def initialize_options(self): """, see_url="https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html", # TODO: Document how to bootstrap setuptools without install - # (e.g. by unziping the wheel file) + # (e.g. by unzipping the wheel file) # and then add a due_date to this warning. ) diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index e64cfa2e4b..1e3a660833 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -168,7 +168,7 @@ def test_excluded_subpackages(tmpdir_cwd): with pytest.warns(SetuptoolsDeprecationWarning, match=msg): # TODO: To fix #3260 we need some transition period to deprecate the # existing behavior of `include_package_data`. After the transition, we - # should remove the warning and fix the behaviour. + # should remove the warning and fix the behavior. if os.getenv("SETUPTOOLS_USE_DISTUTILS") == "stdlib": # pytest.warns reset the warning filter temporarily diff --git a/setuptools/unicode_utils.py b/setuptools/unicode_utils.py index a6e33f2e0d..f502f5b089 100644 --- a/setuptools/unicode_utils.py +++ b/setuptools/unicode_utils.py @@ -86,7 +86,7 @@ class _Utf8EncodingNeeded(SetuptoolsDeprecationWarning): """ _DETAILS = """ - Fallback behaviour for UTF-8 is considered **deprecated** and future versions of + Fallback behavior for UTF-8 is considered **deprecated** and future versions of `setuptools` may not implement it. Please encode {file!r} with "utf-8" to ensure future builds will succeed. From f2febf68696b459c58ad13abde913efc10d8b297 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sun, 23 Feb 2025 15:18:23 +0000 Subject: [PATCH 2/4] Fix more typos --- NEWS.rst | 4 ++-- setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA | 4 ++-- setuptools/_vendor/autocommand/autoasync.py | 8 ++++---- setuptools/_vendor/autocommand/autoparse.py | 6 +++--- setuptools/_vendor/inflect/__init__.py | 2 +- setuptools/_vendor/packaging/metadata.py | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index e9e795005a..bf098df0a5 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -620,7 +620,7 @@ Bugfixes -------- - In tests, rely on pytest-home for reusable fixture. (#4072) -- Explicitely marked as ``Protocol`` and fixed missing ``self`` argument in interfaces ``pkg_resources.IMetadataProvider`` and ``pkg_resources.IResourceProvider`` -- by :user:`Avasam` (#4144) +- Explicitly marked as ``Protocol`` and fixed missing ``self`` argument in interfaces ``pkg_resources.IMetadataProvider`` and ``pkg_resources.IResourceProvider`` -- by :user:`Avasam` (#4144) - Restored expectation that egg-link files would be named with dash separators for compatibility with pip prior to version 24. (#4167) @@ -7151,7 +7151,7 @@ setuptools * Fixed invalid URL error catching. Old Setuptools #20. -* Fixed invalid bootstraping with easy_install installation (Distribute #40). +* Fixed invalid bootstrapping with easy_install installation (Distribute #40). Thanks to Florian Schulze for the help. * Removed buildout/bootstrap.py. A new repository will create a specific diff --git a/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA b/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA index 32214fb440..e153f86374 100644 --- a/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA +++ b/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA @@ -320,7 +320,7 @@ optional arguments: STOP and STEP default to 1 ``` -Even though autocommand is being applied to the `wrapper` returned by `print_yielded`, it still retreives the signature of the underlying `seq` function to create the argument parsing. +Even though autocommand is being applied to the `wrapper` returned by `print_yielded`, it still retrieves the signature of the underlying `seq` function to create the argument parsing. ### Custom Parser @@ -331,7 +331,7 @@ from argparse import ArgumentParser from autocommand import autocommand parser = ArgumentParser() -# autocommand can't do optional positonal parameters +# autocommand can't do optional positional parameters parser.add_argument('arg', nargs='?') # or mutually exclusive options group = parser.add_mutually_exclusive_group() diff --git a/setuptools/_vendor/autocommand/autoasync.py b/setuptools/_vendor/autocommand/autoasync.py index 688f7e0554..0d4825d761 100644 --- a/setuptools/_vendor/autocommand/autoasync.py +++ b/setuptools/_vendor/autocommand/autoasync.py @@ -54,14 +54,14 @@ async def _run_forever_coro(coro, args, kwargs, loop): def autoasync(coro=None, *, loop=None, forever=False, pass_loop=False): ''' Convert an asyncio coroutine into a function which, when called, is - evaluted in an event loop, and the return value returned. This is intented + evaluated in an event loop, and the return value returned. This is intended to make it easy to write entry points into asyncio coroutines, which - otherwise need to be explictly evaluted with an event loop's + otherwise need to be explicitly evaluated with an event loop's run_until_complete. If `loop` is given, it is used as the event loop to run the coro in. If it - is None (the default), the loop is retreived using asyncio.get_event_loop. - This call is defered until the decorated function is called, so that + is None (the default), the loop is retrieved using asyncio.get_event_loop. + This call is deferred until the decorated function is called, so that callers can install custom event loops or event loop policies after @autoasync is applied. diff --git a/setuptools/_vendor/autocommand/autoparse.py b/setuptools/_vendor/autocommand/autoparse.py index 3ed80ed8a4..b50fad83e7 100644 --- a/setuptools/_vendor/autocommand/autoparse.py +++ b/setuptools/_vendor/autocommand/autoparse.py @@ -34,7 +34,7 @@ class AnnotationError(AutocommandError): class PositionalArgError(AutocommandError): ''' - Postional Arg Error: autocommand can't handle postional-only parameters + Positional Arg Error: autocommand can't handle positional-only parameters ''' @@ -197,7 +197,7 @@ def make_parser(func_sig, description, epilog, add_nos): used_char_args = {'h'} # Arange the params so that single-character arguments are first. This - # esnures they don't have to get --long versions. sorted is stable, so the + # ensures they don't have to get --long versions. sorted is stable, so the # parameters will otherwise still be in relative order. params = sorted( func_sig.parameters.values(), @@ -249,7 +249,7 @@ def autoparse( while parameters *with* defaults become --options. Use annotations to set the type of the parameter. - The `desctiption` and `epilog` parameters corrospond to the same respective + The `description` and `epilog` parameters correspond to the same respective argparse parameters. If no description is given, it defaults to the decorated functions's docstring, if present. diff --git a/setuptools/_vendor/inflect/__init__.py b/setuptools/_vendor/inflect/__init__.py index 3eec27f4c6..d9a94b4c99 100644 --- a/setuptools/_vendor/inflect/__init__.py +++ b/setuptools/_vendor/inflect/__init__.py @@ -1837,7 +1837,7 @@ def get_si_pron(thecase, word, gender) -> str: re.VERBOSE, ) -# THIS PATTERN CODES THE BEGINNINGS OF ALL ENGLISH WORDS BEGINING WITH A +# THIS PATTERN CODES THE BEGINNINGS OF ALL ENGLISH WORDS BEGINNING WITH A # 'y' FOLLOWED BY A CONSONANT. ANY OTHER Y-CONSONANT PREFIX THEREFORE # IMPLIES AN ABBREVIATION. diff --git a/setuptools/_vendor/packaging/metadata.py b/setuptools/_vendor/packaging/metadata.py index 7bbfee156d..6a651deb44 100644 --- a/setuptools/_vendor/packaging/metadata.py +++ b/setuptools/_vendor/packaging/metadata.py @@ -424,7 +424,7 @@ def parse_email(data: bytes | str) -> tuple[RawMetadata, dict[str, list[str]]]: except KeyError: unparsed[name] = value # Nothing that we've done has managed to parse this, so it'll just - # throw it in our unparseable data and move on. + # throw it in our unparsable data and move on. else: unparsed[name] = value @@ -441,7 +441,7 @@ def parse_email(data: bytes | str) -> tuple[RawMetadata, dict[str, list[str]]]: else: if payload: # Check to see if we've already got a description, if so then both - # it, and this body move to unparseable. + # it, and this body move to unparsable. if "description" in raw: description_header = cast(str, raw.pop("description")) unparsed.setdefault("description", []).extend( From e470e9e97da8621dd991e06057ef97db981e897d Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sun, 23 Feb 2025 15:21:07 +0000 Subject: [PATCH 3/4] Revert remove TODO comment code --- pkg_resources/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 86caf45177..68feeb0593 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -3326,6 +3326,9 @@ def has_version(self) -> bool: except ValueError: issue_warning("Unbuilt egg for " + repr(self)) return False + except SystemError: + # TODO: remove this except clause when python/cpython#103632 is fixed. + return False return True def clone(self, **kw: str | int | IResourceProvider | None) -> Self: From 9b0d98cce8577593eb6c87931ea6b91f360739db Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Wed, 26 Feb 2025 03:28:12 +0000 Subject: [PATCH 4/4] Revert change files under _vendor --- .../_vendor/autocommand-2.2.2.dist-info/METADATA | 4 ++-- setuptools/_vendor/autocommand/autoasync.py | 8 ++++---- setuptools/_vendor/autocommand/autoparse.py | 8 ++++---- setuptools/_vendor/inflect/__init__.py | 2 +- setuptools/_vendor/packaging/metadata.py | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA b/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA index e153f86374..32214fb440 100644 --- a/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA +++ b/setuptools/_vendor/autocommand-2.2.2.dist-info/METADATA @@ -320,7 +320,7 @@ optional arguments: STOP and STEP default to 1 ``` -Even though autocommand is being applied to the `wrapper` returned by `print_yielded`, it still retrieves the signature of the underlying `seq` function to create the argument parsing. +Even though autocommand is being applied to the `wrapper` returned by `print_yielded`, it still retreives the signature of the underlying `seq` function to create the argument parsing. ### Custom Parser @@ -331,7 +331,7 @@ from argparse import ArgumentParser from autocommand import autocommand parser = ArgumentParser() -# autocommand can't do optional positional parameters +# autocommand can't do optional positonal parameters parser.add_argument('arg', nargs='?') # or mutually exclusive options group = parser.add_mutually_exclusive_group() diff --git a/setuptools/_vendor/autocommand/autoasync.py b/setuptools/_vendor/autocommand/autoasync.py index 0d4825d761..688f7e0554 100644 --- a/setuptools/_vendor/autocommand/autoasync.py +++ b/setuptools/_vendor/autocommand/autoasync.py @@ -54,14 +54,14 @@ async def _run_forever_coro(coro, args, kwargs, loop): def autoasync(coro=None, *, loop=None, forever=False, pass_loop=False): ''' Convert an asyncio coroutine into a function which, when called, is - evaluated in an event loop, and the return value returned. This is intended + evaluted in an event loop, and the return value returned. This is intented to make it easy to write entry points into asyncio coroutines, which - otherwise need to be explicitly evaluated with an event loop's + otherwise need to be explictly evaluted with an event loop's run_until_complete. If `loop` is given, it is used as the event loop to run the coro in. If it - is None (the default), the loop is retrieved using asyncio.get_event_loop. - This call is deferred until the decorated function is called, so that + is None (the default), the loop is retreived using asyncio.get_event_loop. + This call is defered until the decorated function is called, so that callers can install custom event loops or event loop policies after @autoasync is applied. diff --git a/setuptools/_vendor/autocommand/autoparse.py b/setuptools/_vendor/autocommand/autoparse.py index b50fad83e7..0276a3fae1 100644 --- a/setuptools/_vendor/autocommand/autoparse.py +++ b/setuptools/_vendor/autocommand/autoparse.py @@ -34,7 +34,7 @@ class AnnotationError(AutocommandError): class PositionalArgError(AutocommandError): ''' - Positional Arg Error: autocommand can't handle positional-only parameters + Postional Arg Error: autocommand can't handle postional-only parameters ''' @@ -137,7 +137,7 @@ def _add_arguments(param, parser, used_char_args, add_nos): arg_spec['type'] = str # TODO: special case for list type. - # - How to specify type of list members? + # - How to specificy type of list members? # - param: [int] # - param: int =[] # - action='append' vs nargs='*' @@ -197,7 +197,7 @@ def make_parser(func_sig, description, epilog, add_nos): used_char_args = {'h'} # Arange the params so that single-character arguments are first. This - # ensures they don't have to get --long versions. sorted is stable, so the + # esnures they don't have to get --long versions. sorted is stable, so the # parameters will otherwise still be in relative order. params = sorted( func_sig.parameters.values(), @@ -249,7 +249,7 @@ def autoparse( while parameters *with* defaults become --options. Use annotations to set the type of the parameter. - The `description` and `epilog` parameters correspond to the same respective + The `desctiption` and `epilog` parameters corrospond to the same respective argparse parameters. If no description is given, it defaults to the decorated functions's docstring, if present. diff --git a/setuptools/_vendor/inflect/__init__.py b/setuptools/_vendor/inflect/__init__.py index d9a94b4c99..3eec27f4c6 100644 --- a/setuptools/_vendor/inflect/__init__.py +++ b/setuptools/_vendor/inflect/__init__.py @@ -1837,7 +1837,7 @@ def get_si_pron(thecase, word, gender) -> str: re.VERBOSE, ) -# THIS PATTERN CODES THE BEGINNINGS OF ALL ENGLISH WORDS BEGINNING WITH A +# THIS PATTERN CODES THE BEGINNINGS OF ALL ENGLISH WORDS BEGINING WITH A # 'y' FOLLOWED BY A CONSONANT. ANY OTHER Y-CONSONANT PREFIX THEREFORE # IMPLIES AN ABBREVIATION. diff --git a/setuptools/_vendor/packaging/metadata.py b/setuptools/_vendor/packaging/metadata.py index 6a651deb44..721f411cfc 100644 --- a/setuptools/_vendor/packaging/metadata.py +++ b/setuptools/_vendor/packaging/metadata.py @@ -193,10 +193,10 @@ def _parse_project_urls(data: list[str]) -> dict[str, str]: # be the missing value, then they'd have multiple '' values that # overwrite each other in a accumulating dict. # - # The other potential issue is that it's possible to have the + # The other potentional issue is that it's possible to have the # same label multiple times in the metadata, with no solid "right" # answer with what to do in that case. As such, we'll do the only - # thing we can, which is treat the field as unparsable and add it + # thing we can, which is treat the field as unparseable and add it # to our list of unparsed fields. parts = [p.strip() for p in pair.split(",", 1)] parts.extend([""] * (max(0, 2 - len(parts)))) # Ensure 2 items @@ -209,8 +209,8 @@ def _parse_project_urls(data: list[str]) -> dict[str, str]: label, url = parts if label in urls: # The label already exists in our set of urls, so this field - # is unparsable, and we can just add the whole thing to our - # unparsable data and stop processing it. + # is unparseable, and we can just add the whole thing to our + # unparseable data and stop processing it. raise KeyError("duplicate labels in project urls") urls[label] = url @@ -424,7 +424,7 @@ def parse_email(data: bytes | str) -> tuple[RawMetadata, dict[str, list[str]]]: except KeyError: unparsed[name] = value # Nothing that we've done has managed to parse this, so it'll just - # throw it in our unparsable data and move on. + # throw it in our unparseable data and move on. else: unparsed[name] = value @@ -441,7 +441,7 @@ def parse_email(data: bytes | str) -> tuple[RawMetadata, dict[str, list[str]]]: else: if payload: # Check to see if we've already got a description, if so then both - # it, and this body move to unparsable. + # it, and this body move to unparseable. if "description" in raw: description_header = cast(str, raw.pop("description")) unparsed.setdefault("description", []).extend(