diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..2390d8c8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index bd06d11d..186199a5 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,11 +31,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@1500a131381b66de0c52ac28abb13cd79f4b7ecc # v2.22.12 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@v2 + uses: github/codeql-action/autobuild@1500a131381b66de0c52ac28abb13cd79f4b7ecc # v2.22.12 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@1500a131381b66de0c52ac28abb13cd79f4b7ecc # v2.22.12 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 53bca63b..50cfb956 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -20,9 +20,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 name: Install Python with: python-version: "3.9" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 712704c1..652a2f92 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,9 +22,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 name: Install Python with: python-version: "3.9" @@ -43,13 +43,13 @@ jobs: needs: lint steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Build run: pipx run build - name: Archive files - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 with: name: dist path: dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa908728..8f81945e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,9 +26,9 @@ jobs: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9", "pypy3.10"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1 name: Install Python ${{ matrix.python_version }} with: python-version: ${{ matrix.python_version }} diff --git a/docs/development/getting-started.rst b/docs/development/getting-started.rst index cb751d67..a713eac8 100644 --- a/docs/development/getting-started.rst +++ b/docs/development/getting-started.rst @@ -73,5 +73,5 @@ The HTML documentation index can now be found at .. _`virtualenv`: https://pypi.org/project/virtualenv/ .. _`pip`: https://pypi.org/project/pip/ .. _`sphinx`: https://pypi.org/project/Sphinx/ -.. _`reStructured Text`: http://sphinx-doc.org/rest.html +.. _`reStructured Text`: https://www.sphinx-doc.org/en/master/usage/restructuredtext/ .. _`pre-commit`: https://pre-commit.com diff --git a/docs/development/index.rst b/docs/development/index.rst index c0aea8ac..767f0885 100644 --- a/docs/development/index.rst +++ b/docs/development/index.rst @@ -16,4 +16,4 @@ bug check out `what to put in your bug report`_. release-process .. _`GitHub`: https://github.com/pypa/packaging -.. _`what to put in your bug report`: http://www.contribution-guide.org/#what-to-put-in-your-bug-report +.. _`what to put in your bug report`: https://www.contribution-guide.org/#what-to-put-in-your-bug-report diff --git a/docs/development/submitting-patches.rst b/docs/development/submitting-patches.rst index fbdb5a4d..d05637a6 100644 --- a/docs/development/submitting-patches.rst +++ b/docs/development/submitting-patches.rst @@ -70,5 +70,5 @@ So, specifically: .. |black| replace:: ``black`` .. _black: https://pypi.org/project/black/ .. _`Write comments as complete sentences.`: https://nedbatchelder.com/blog/201401/comments_should_be_sentences.html -.. _`syntax`: http://sphinx-doc.org/domains.html#info-field-lists -.. _`Studies have shown`: http://www.ibm.com/developerworks/rational/library/11-proven-practices-for-peer-review/ +.. _`syntax`: https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html +.. _`Studies have shown`: https://www.microsoft.com/en-us/research/publication/characteristics-of-useful-code-reviews-an-empirical-study-at-microsoft/ diff --git a/src/packaging/_manylinux.py b/src/packaging/_manylinux.py index 0a9cf414..ad62505f 100644 --- a/src/packaging/_manylinux.py +++ b/src/packaging/_manylinux.py @@ -90,7 +90,7 @@ def _glibc_version_string_confstr() -> Optional[str]: # https://github.com/python/cpython/blob/fcf1d003bf4f0100c/Lib/platform.py#L175-L183 try: # Should be a string like "glibc 2.17". - version_string: str = getattr(os, "confstr")("CS_GNU_LIBC_VERSION") + version_string: Optional[str] = os.confstr("CS_GNU_LIBC_VERSION") assert version_string is not None _, version = version_string.rsplit() except (AssertionError, AttributeError, OSError, ValueError): @@ -182,7 +182,7 @@ def _is_compatible(arch: str, version: _GLibCVersion) -> bool: return False # Check for presence of _manylinux module. try: - import _manylinux # noqa + import _manylinux except ImportError: return True if hasattr(_manylinux, "manylinux_compatible"): diff --git a/src/packaging/_parser.py b/src/packaging/_parser.py index 4576981c..684df754 100644 --- a/src/packaging/_parser.py +++ b/src/packaging/_parser.py @@ -324,10 +324,7 @@ def _parse_marker_var(tokenizer: Tokenizer) -> MarkerVar: def process_env_var(env_var: str) -> Variable: - if ( - env_var == "platform_python_implementation" - or env_var == "python_implementation" - ): + if env_var in ("platform_python_implementation", "python_implementation"): return Variable("platform_python_implementation") else: return Variable(env_var) diff --git a/src/packaging/requirements.py b/src/packaging/requirements.py index 0c00eba3..bdc43a7e 100644 --- a/src/packaging/requirements.py +++ b/src/packaging/requirements.py @@ -38,7 +38,7 @@ def __init__(self, requirement_string: str) -> None: self.name: str = parsed.name self.url: Optional[str] = parsed.url or None - self.extras: Set[str] = set(parsed.extras if parsed.extras else []) + self.extras: Set[str] = set(parsed.extras or []) self.specifier: SpecifierSet = SpecifierSet(parsed.specifier) self.marker: Optional[Marker] = None if parsed.marker is not None: diff --git a/src/packaging/specifiers.py b/src/packaging/specifiers.py index 94448327..2d015bab 100644 --- a/src/packaging/specifiers.py +++ b/src/packaging/specifiers.py @@ -11,17 +11,7 @@ import abc import itertools import re -from typing import ( - Callable, - Iterable, - Iterator, - List, - Optional, - Set, - Tuple, - TypeVar, - Union, -) +from typing import Callable, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union from .utils import canonicalize_version from .version import Version @@ -697,7 +687,10 @@ def _pad_version(left: List[str], right: List[str]) -> Tuple[List[str], List[str left_split.insert(1, ["0"] * max(0, len(right_split[0]) - len(left_split[0]))) right_split.insert(1, ["0"] * max(0, len(left_split[0]) - len(right_split[0]))) - return (list(itertools.chain(*left_split)), list(itertools.chain(*right_split))) + return ( + list(itertools.chain.from_iterable(left_split)), + list(itertools.chain.from_iterable(right_split)), + ) class SpecifierSet(BaseSpecifier): @@ -729,14 +722,8 @@ def __init__( # strip each item to remove leading/trailing whitespace. split_specifiers = [s.strip() for s in specifiers.split(",") if s.strip()] - # Parsed each individual specifier, attempting first to make it a - # Specifier. - parsed: Set[Specifier] = set() - for specifier in split_specifiers: - parsed.add(Specifier(specifier)) - - # Turn our parsed specifiers into a frozen set and save them for later. - self._specs = frozenset(parsed) + # Make each individual specifier a Specifier and save in a frozen set for later. + self._specs = frozenset(map(Specifier, split_specifiers)) # Store our prereleases value so we can use it later to determine if # we accept prereleases or not. diff --git a/tests/test_specifiers.py b/tests/test_specifiers.py index ebcd9d98..a79b860e 100644 --- a/tests/test_specifiers.py +++ b/tests/test_specifiers.py @@ -235,8 +235,7 @@ def test_specifiers_hash(self, specifier): @pytest.mark.parametrize( ("left", "right", "op"), - itertools.chain( - * + itertools.chain.from_iterable( # Verify that the equal (==) operator works correctly [[(x, x, operator.eq) for x in SPECIFIERS]] + @@ -260,8 +259,7 @@ def test_comparison_canonicalizes(self, left, right): @pytest.mark.parametrize( ("left", "right", "op"), - itertools.chain( - * + itertools.chain.from_iterable( # Verify that the equal (==) operator works correctly [[(x, x, operator.ne) for x in SPECIFIERS]] + @@ -815,8 +813,7 @@ def test_specifiers_combine_not_implemented(self): @pytest.mark.parametrize( ("left", "right", "op"), - itertools.chain( - * + itertools.chain.from_iterable( # Verify that the equal (==) operator works correctly [[(x, x, operator.eq) for x in SPECIFIERS]] + @@ -836,8 +833,7 @@ def test_comparison_true(self, left, right, op): @pytest.mark.parametrize( ("left", "right", "op"), - itertools.chain( - * + itertools.chain.from_iterable( # Verify that the equal (==) operator works correctly [[(x, x, operator.ne) for x in SPECIFIERS]] + diff --git a/tests/test_structures.py b/tests/test_structures.py index f8115e57..cc651cf6 100644 --- a/tests/test_structures.py +++ b/tests/test_structures.py @@ -8,11 +8,11 @@ def test_infinity_repr(): - repr(Infinity) == "Infinity" + assert repr(Infinity) == "Infinity" def test_negative_infinity_repr(): - repr(NegativeInfinity) == "-Infinity" + assert repr(NegativeInfinity) == "-Infinity" def test_infinity_hash(): diff --git a/tests/test_version.py b/tests/test_version.py index 8004c0cc..6cdbe190 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -667,8 +667,7 @@ def test_version_is_postrelease(self, version, expected): ("left", "right", "op"), # Below we'll generate every possible combination of VERSIONS that # should be True for the given operator - itertools.chain( - * + itertools.chain.from_iterable( # Verify that the less than (<) operator works correctly [ [(x, y, operator.lt) for y in VERSIONS[i + 1 :]] @@ -710,8 +709,7 @@ def test_comparison_true(self, left, right, op): ("left", "right", "op"), # Below we'll generate every possible combination of VERSIONS that # should be False for the given operator - itertools.chain( - * + itertools.chain.from_iterable( # Verify that the less than (<) operator works correctly [ [(x, y, operator.lt) for y in VERSIONS[: i + 1]]