From 7a983f7f0068669ead9d4f7571be24d6c0d83eb9 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sun, 10 Mar 2024 09:38:55 +0000 Subject: [PATCH 1/6] Bump for release --- CHANGELOG.rst | 4 ++-- src/packaging/__init__.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 153c2af6..68dfb801 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,8 +1,8 @@ Changelog --------- -*unreleased* -~~~~~~~~~~~~ +24.0 - 2024-03-10 +~~~~~~~~~~~~~~~~~ * Do specifier matching correctly when the specifier contains an epoch number and has more components than the version (:issue:`683`) diff --git a/src/packaging/__init__.py b/src/packaging/__init__.py index 5fd91838..e7c0aa12 100644 --- a/src/packaging/__init__.py +++ b/src/packaging/__init__.py @@ -6,7 +6,7 @@ __summary__ = "Core utilities for Python packages" __uri__ = "https://github.com/pypa/packaging" -__version__ = "23.3.dev0" +__version__ = "24.0" __author__ = "Donald Stufft and individual contributors" __email__ = "donald@stufft.io" From e8002b16e79c71a5f256d4f20eee0170f4327dd9 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sun, 10 Mar 2024 09:38:56 +0000 Subject: [PATCH 2/6] Bump for development --- CHANGELOG.rst | 5 +++++ src/packaging/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 68dfb801..c0d78f86 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ Changelog --------- +*unreleased* +~~~~~~~~~~~~ + +No unreleased changes. + 24.0 - 2024-03-10 ~~~~~~~~~~~~~~~~~ diff --git a/src/packaging/__init__.py b/src/packaging/__init__.py index e7c0aa12..658836a9 100644 --- a/src/packaging/__init__.py +++ b/src/packaging/__init__.py @@ -6,7 +6,7 @@ __summary__ = "Core utilities for Python packages" __uri__ = "https://github.com/pypa/packaging" -__version__ = "24.0" +__version__ = "24.1.dev0" __author__ = "Donald Stufft and individual contributors" __email__ = "donald@stufft.io" From cb8fd38ef4c4189142702951b89dee1f09e4d71f Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 10 Mar 2024 10:46:07 +0100 Subject: [PATCH 3/6] =?UTF-8?q?pyupgrade/black/isort/flake8=20=E2=86=92=20?= =?UTF-8?q?ruff=20(#769)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flake8 | 3 --- .pre-commit-config.yaml | 27 +++++------------------- pyproject.toml | 42 ++++++++++++++++++++++++++++++++++--- src/packaging/markers.py | 3 ++- src/packaging/metadata.py | 5 +++-- src/packaging/specifiers.py | 6 ------ src/packaging/version.py | 2 -- 7 files changed, 49 insertions(+), 39 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index b5a35be9..00000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 88 -ignore = E203,W503,W504 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c03c4d43..8dc94e9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,26 +15,9 @@ repos: args: [] additional_dependencies: [pyparsing, nox] - - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.11 hooks: - - id: pyupgrade - args: [--py37-plus] - - - repo: https://github.com/psf/black - rev: 22.12.0 - hooks: - - id: black - - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - - - repo: https://github.com/PyCQA/flake8 - rev: "6.0.0" - hooks: - - id: flake8 - additional_dependencies: ["pep8-naming"] - # Ignore all format-related checks as Black takes care of those. - args: ["--ignore", "E2,W5", "--select", "E,W,F,N"] + - id: ruff + args: [ --fix ] + - id: ruff-format diff --git a/pyproject.toml b/pyproject.toml index 9fa0fb17..f115bb75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,6 +57,42 @@ module = ["_manylinux"] ignore_missing_imports = true -[tool.isort] -profile = "black" -combine_as_imports = true +[tool.ruff] +src = ["src"] + +[tool.ruff.lint] +extend-select = [ + "B", + "E", + "F", + "I", + "N", + "UP", + "W" +] +ignore = [ + "B009", + "B015", + "B018", + "B027", + "B028", + "B904", + "N818", + "UP032", + "UP030", + # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + "W191", + "E111", + "E114", + "E117", + "D206", + "D300", + "Q000", + "Q001", + "Q002", + "Q003", + "COM812", + "COM819", + "ISC001", + "ISC002", +] diff --git a/src/packaging/markers.py b/src/packaging/markers.py index 8b98fca7..c96d22a5 100644 --- a/src/packaging/markers.py +++ b/src/packaging/markers.py @@ -14,6 +14,8 @@ Op, Value, Variable, +) +from ._parser import ( parse_marker as _parse_marker, ) from ._tokenizer import ParserSyntaxError @@ -69,7 +71,6 @@ def _normalize_extra_values(results: Any) -> Any: def _format_marker( marker: Union[List[str], MarkerAtom, str], first: Optional[bool] = True ) -> str: - assert isinstance(marker, (list, tuple, str)) # Sometimes we have a structure like [[...]] which is a single item list diff --git a/src/packaging/metadata.py b/src/packaging/metadata.py index fb274930..80f46d19 100644 --- a/src/packaging/metadata.py +++ b/src/packaging/metadata.py @@ -18,7 +18,8 @@ cast, ) -from . import requirements, specifiers, utils, version as version_module +from . import requirements, specifiers, utils +from . import version as version_module T = typing.TypeVar("T") if sys.version_info[:2] >= (3, 8): # pragma: no cover @@ -44,7 +45,7 @@ def __init_subclass__(*_args, **_kwargs): ExceptionGroup except NameError: # pragma: no cover - class ExceptionGroup(Exception): # noqa: N818 + class ExceptionGroup(Exception): """A minimal implementation of :external:exc:`ExceptionGroup` from Python 3.11. If :external:exc:`ExceptionGroup` is already defined by Python itself, diff --git a/src/packaging/specifiers.py b/src/packaging/specifiers.py index 2d015bab..6d4066ae 100644 --- a/src/packaging/specifiers.py +++ b/src/packaging/specifiers.py @@ -364,7 +364,6 @@ def _get_operator(self, op: str) -> CallableOperator: return operator_callable def _compare_compatible(self, prospective: Version, spec: str) -> bool: - # Compatible releases have an equivalent combination of >= and ==. That # is that ~=2.2 is equivalent to >=2.2,==2.*. This allows us to # implement this in terms of the other specifiers instead of @@ -385,7 +384,6 @@ def _compare_compatible(self, prospective: Version, spec: str) -> bool: ) def _compare_equal(self, prospective: Version, spec: str) -> bool: - # We need special logic to handle prefix matching if spec.endswith(".*"): # In the case of prefix matching we want to ignore local segment. @@ -429,21 +427,18 @@ def _compare_not_equal(self, prospective: Version, spec: str) -> bool: return not self._compare_equal(prospective, spec) def _compare_less_than_equal(self, prospective: Version, spec: str) -> bool: - # NB: Local version identifiers are NOT permitted in the version # specifier, so local version labels can be universally removed from # the prospective version. return Version(prospective.public) <= Version(spec) def _compare_greater_than_equal(self, prospective: Version, spec: str) -> bool: - # NB: Local version identifiers are NOT permitted in the version # specifier, so local version labels can be universally removed from # the prospective version. return Version(prospective.public) >= Version(spec) def _compare_less_than(self, prospective: Version, spec_str: str) -> bool: - # Convert our spec to a Version instance, since we'll want to work with # it as a version. spec = Version(spec_str) @@ -468,7 +463,6 @@ def _compare_less_than(self, prospective: Version, spec_str: str) -> bool: return True def _compare_greater_than(self, prospective: Version, spec_str: str) -> bool: - # Convert our spec to a Version instance, since we'll want to work with # it as a version. spec = Version(spec_str) diff --git a/src/packaging/version.py b/src/packaging/version.py index 5faab9bd..cda8e999 100644 --- a/src/packaging/version.py +++ b/src/packaging/version.py @@ -452,7 +452,6 @@ def micro(self) -> int: def _parse_letter_version( letter: Optional[str], number: Union[str, bytes, SupportsInt, None] ) -> Optional[Tuple[str, int]]: - if letter: # We consider there to be an implicit 0 in a pre-release if there is # not a numeral associated with it. @@ -508,7 +507,6 @@ def _cmpkey( dev: Optional[Tuple[str, int]], local: Optional[LocalType], ) -> CmpKey: - # When we compare a release version, we want to compare it with all of the # trailing zeros removed. So we'll use a reverse the list, drop all the now # leading zeros until we come to something non zero, then take the rest From 5cbe1e44cc7b0497a11ab441310a86a5ebf1658a Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sun, 10 Mar 2024 11:49:04 +0200 Subject: [PATCH 4/6] Add support for Python 3.13 and drop EOL 3.7 (#783) Co-authored-by: Pradyun Gedam --- .github/workflows/docs.yml | 3 +++ .github/workflows/lint.yml | 3 +++ .github/workflows/test.yml | 5 ++++- docs/development/getting-started.rst | 8 ++++++-- noxfile.py | 2 +- pyproject.toml | 4 ++-- src/packaging/_manylinux.py | 2 +- src/packaging/_musllinux.py | 2 +- src/packaging/metadata.py | 20 ++------------------ 9 files changed, 23 insertions(+), 26 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 50cfb956..cc614f0f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,6 +14,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true +env: + FORCE_COLOR: 1 + jobs: docs: name: nox -s docs diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 652a2f92..2c1829dd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,6 +16,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true +env: + FORCE_COLOR: 1 + jobs: lint: name: nox -s lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f81945e..debdb74d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true +env: + FORCE_COLOR: 1 + jobs: test: name: ${{ matrix.os }} / ${{ matrix.python_version }} @@ -23,7 +26,7 @@ jobs: matrix: os: [Ubuntu, Windows, macOS] python_version: - ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9", "pypy3.10"] + ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.8", "pypy3.9", "pypy3.10"] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 diff --git a/docs/development/getting-started.rst b/docs/development/getting-started.rst index a713eac8..0cad38ae 100644 --- a/docs/development/getting-started.rst +++ b/docs/development/getting-started.rst @@ -30,11 +30,15 @@ each supported Python version and run the tests. For example: $ nox -s tests ... nox > Ran multiple sessions: - nox > * tests-3.7: success nox > * tests-3.8: success nox > * tests-3.9: success nox > * tests-3.10: success - nox > * tests-pypy3: skipped + nox > * tests-3.11: success + nox > * tests-3.12: success + nox > * tests-3.13: success + nox > * tests-pypy3.8: skipped + nox > * tests-pypy3.9: skipped + nox > * tests-pypy3.10: skipped You may not have all the required Python versions installed, in which case you will see one or more ``InterpreterNotFound`` errors. diff --git a/noxfile.py b/noxfile.py index 4f97e8e5..454ba21c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,12 +23,12 @@ @nox.session( python=[ - "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", + "3.13", "pypy3.8", "pypy3.9", "pypy3.10", diff --git a/pyproject.toml b/pyproject.toml index f115bb75..5deff4d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ name = "packaging" description = "Core utilities for Python packages" dynamic = ["version"] readme = "README.rst" -requires-python = ">=3.7" +requires-python = ">=3.8" authors = [{name = "Donald Stufft", email = "donald@stufft.io"}] classifiers = [ "Development Status :: 5 - Production/Stable", @@ -18,12 +18,12 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Typing :: Typed", diff --git a/src/packaging/_manylinux.py b/src/packaging/_manylinux.py index ad62505f..1f5f4ab3 100644 --- a/src/packaging/_manylinux.py +++ b/src/packaging/_manylinux.py @@ -167,7 +167,7 @@ def _parse_glibc_version(version_str: str) -> Tuple[int, int]: return int(m.group("major")), int(m.group("minor")) -@functools.lru_cache() +@functools.lru_cache def _get_glibc_version() -> Tuple[int, int]: version_str = _glibc_version_string() if version_str is None: diff --git a/src/packaging/_musllinux.py b/src/packaging/_musllinux.py index 86419df9..eb4251b5 100644 --- a/src/packaging/_musllinux.py +++ b/src/packaging/_musllinux.py @@ -28,7 +28,7 @@ def _parse_musl_version(output: str) -> Optional[_MuslVersion]: return _MuslVersion(major=int(m.group(1)), minor=int(m.group(2))) -@functools.lru_cache() +@functools.lru_cache def _get_musl_version(executable: str) -> Optional[_MuslVersion]: """Detect currently-running musl runtime version. diff --git a/src/packaging/metadata.py b/src/packaging/metadata.py index 80f46d19..fe835071 100644 --- a/src/packaging/metadata.py +++ b/src/packaging/metadata.py @@ -3,7 +3,6 @@ import email.message import email.parser import email.policy -import sys import typing from typing import ( Any, @@ -11,9 +10,11 @@ Dict, Generic, List, + Literal, Optional, Tuple, Type, + TypedDict, Union, cast, ) @@ -22,23 +23,6 @@ from . import version as version_module T = typing.TypeVar("T") -if sys.version_info[:2] >= (3, 8): # pragma: no cover - from typing import Literal, TypedDict -else: # pragma: no cover - if typing.TYPE_CHECKING: - from typing_extensions import Literal, TypedDict - else: - try: - from typing_extensions import Literal, TypedDict - except ImportError: - - class Literal: - def __init_subclass__(*_args, **_kwargs): - pass - - class TypedDict: - def __init_subclass__(*_args, **_kwargs): - pass try: From ec9f203a9f1d336d62b71a26e3ad3dfcfbef92dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Mar 2024 05:50:04 -0400 Subject: [PATCH 5/6] Bump the github-actions group with 4 updates (#782) --- .github/workflows/codeql.yml | 8 ++++---- .github/workflows/docs.yml | 4 ++-- .github/workflows/lint.yml | 8 ++++---- .github/workflows/test.yml | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 186199a5..4f88e578 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,11 +31,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@1500a131381b66de0c52ac28abb13cd79f4b7ecc # v2.22.12 + uses: github/codeql-action/init@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -47,9 +47,9 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - name: Autobuild - uses: github/codeql-action/autobuild@1500a131381b66de0c52ac28abb13cd79f4b7ecc # v2.22.12 + uses: github/codeql-action/autobuild@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@1500a131381b66de0c52ac28abb13cd79f4b7ecc # v2.22.12 + uses: github/codeql-action/analyze@8a470fddafa5cbb6266ee11b37ef4d8aae19c571 # v3.24.6 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index cc614f0f..31fefd8c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,9 +23,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 name: Install Python with: python-version: "3.9" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2c1829dd..96ce3b6a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,9 +25,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 name: Install Python with: python-version: "3.9" @@ -46,13 +46,13 @@ jobs: needs: lint steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Build run: pipx run build - name: Archive files - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: name: dist path: dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index debdb74d..61b42f82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,9 +29,9 @@ jobs: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.8", "pypy3.9", "pypy3.10"] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 name: Install Python ${{ matrix.python_version }} with: python-version: ${{ matrix.python_version }} From 757f559404ff6cc1cdef59a2c3628ccdaa505ac4 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sun, 10 Mar 2024 10:50:33 +0000 Subject: [PATCH 6/6] Fix typo in `_parser` docstring (#784) --- src/packaging/_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packaging/_parser.py b/src/packaging/_parser.py index 684df754..513686a2 100644 --- a/src/packaging/_parser.py +++ b/src/packaging/_parser.py @@ -1,6 +1,6 @@ """Handwritten parser of dependency specifiers. -The docstring for each __parse_* function contains ENBF-inspired grammar representing +The docstring for each __parse_* function contains EBNF-inspired grammar representing the implementation. """