Skip to content

Commit b6b7da6

Browse files
committed
Merge remote-tracking branch 'upstream/main' into publish-ci-workflow
2 parents 7b7127e + 4b01511 commit b6b7da6

40 files changed

+2986
-728
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
# Initializes the CodeQL tools for scanning.
3737
- name: Initialize CodeQL
38-
uses: github/codeql-action/init@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.29.5
38+
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5
3939
with:
4040
languages: ${{ matrix.language }}
4141
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -47,9 +47,9 @@ jobs:
4747

4848
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
4949
- name: Autobuild
50-
uses: github/codeql-action/autobuild@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.29.5
50+
uses: github/codeql-action/autobuild@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5
5151

5252
- name: Perform CodeQL Analysis
53-
uses: github/codeql-action/analyze@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.29.5
53+
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5
5454
with:
5555
category: "/language:${{matrix.language}}"

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2929

30-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
30+
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
3131
name: Install Python
3232
with:
3333
python-version: "3.9"

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2929

30-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
30+
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
3131
name: Install Python
3232
with:
3333
python-version: "3.9"
@@ -55,7 +55,7 @@ jobs:
5555
run: pipx run twine check --strict ./dist/*
5656

5757
- name: Archive files
58-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
58+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
5959
with:
6060
name: dist
6161
path: dist

.github/workflows/test.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3333

34-
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
34+
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
3535
name: Install Python ${{ matrix.python_version }}
3636
with:
3737
python-version: ${{ matrix.python_version }}
@@ -40,3 +40,18 @@ jobs:
4040

4141
- name: Run nox
4242
run: pipx run nox --error-on-missing-interpreters -s tests-${{ matrix.python_version }}
43+
44+
pass:
45+
name: All pass
46+
if: always()
47+
48+
needs:
49+
- test
50+
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: Decide whether the needed jobs succeeded or failed
55+
uses: re-actors/alls-green@release/v1
56+
with:
57+
jobs: ${{ toJSON(needs) }}

.pre-commit-config.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-toml
66
- id: check-yaml
77
- id: end-of-file-fixer
88
- id: mixed-line-ending
99
- id: trailing-whitespace
1010

11-
- repo: https://github.com/pre-commit/mirrors-mypy
12-
rev: v1.15.0
13-
hooks:
14-
- id: mypy
15-
exclude: '^(docs|tasks|tests)|setup\.py'
16-
args: []
17-
additional_dependencies: [pyparsing, nox, orjson]
18-
1911
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.11.8
12+
rev: v0.13.0
2113
hooks:
22-
- id: ruff
14+
- id: ruff-check
2315
args: [ --fix, --show-fixes ]
2416
- id: ruff-format
2517

@@ -30,6 +22,14 @@ repos:
3022
- id: rst-directive-colons
3123
- id: rst-inline-touching-normal
3224

25+
- repo: https://github.com/pre-commit/mirrors-mypy
26+
rev: v1.18.1
27+
hooks:
28+
- id: mypy
29+
exclude: '^(docs)'
30+
args: []
31+
additional_dependencies: [pyparsing, nox, orjson, 'pytest<9', tomli, tomli_w, types-invoke, httpx]
32+
3333
- repo: https://github.com/codespell-project/codespell
3434
rev: "v2.4.1"
3535
hooks:

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The ``packaging`` library uses calendar-based versioning (``YY.N``).
3030
requirements
3131
metadata
3232
tags
33+
pylock
3334
utils
3435

3536
.. toctree::

docs/pylock.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Lock Files
2+
==========
3+
4+
.. currentmodule:: packaging.pylock
5+
6+
Parse and validate `pylock.toml files <https://packaging.python.org/en/latest/specifications/pylock-toml/>`_.
7+
8+
Usage
9+
-----
10+
11+
.. code-block:: python
12+
13+
import tomllib
14+
from pathlib import Path
15+
16+
from packaging.pylock import Package, PackageWheel, Pylock
17+
from packaging.utils import NormalizedName
18+
from packaging.version import Version
19+
20+
# validate a pylock file name
21+
assert is_valid_pylock_path(Path("pylock.example.toml"))
22+
23+
# parse and validate pylock file
24+
toml_dict = tomllib.loads(Path("pylock.toml").read_text(encoding="utf-8"))
25+
pylock = PyLock.from_dict(toml_dict)
26+
# the resulting pylock object is validated against the specification,
27+
# else a PylockValidationError is raised
28+
29+
# generate a pylock file
30+
pylock = Pylock(
31+
lock_version=Version("1.0"),
32+
created_by="some_tool",
33+
packages=[
34+
Package(
35+
name=NormalizedName("example-package"),
36+
version=Version("1.0.0"),
37+
wheels=[
38+
PackageWheel(
39+
url="https://example.com/example_package-1.0.0-py3-none-any.whl",
40+
hashes={"sha256": "0fd.."},
41+
)
42+
],
43+
)
44+
],
45+
)
46+
toml_dict = pylock.to_dict()
47+
# use a third-party library to serialize to TOML
48+
49+
# you can validate a manually constructed Pylock class
50+
pylock.validate()
51+
52+
Reference
53+
---------
54+
55+
.. autofunction:: is_valid_pylock_path
56+
57+
The following frozen keyword-only dataclasses are used to represent the
58+
structure of a pylock file. The attributes correspond to the fields in the
59+
pylock file specification.
60+
61+
.. autoclass:: Pylock
62+
:members: from_dict, to_dict, validate
63+
:exclude-members: __init__, __new__
64+
65+
.. class:: Package
66+
67+
.. class:: PackageWheel
68+
69+
.. class:: PackageSdist
70+
71+
.. class:: PackageArchive
72+
73+
.. class:: PackageVcs
74+
75+
.. class:: PackageDirectory
76+
77+
The following exception may be raised by this module:
78+
79+
.. autoexception:: PylockValidationError
80+
:exclude-members: __init__, __new__
81+
82+
.. autoexception:: PylockUnsupportedVersionError
83+
:exclude-members: __init__, __new__

docs/utils.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ Reference
8181
:class:`~packaging.version.Version`. The build number is ``()`` if
8282
there is no build number in the wheel filename, otherwise a
8383
two-item tuple of an integer for the leading digits and
84-
a string for the rest of the build number. The tags portion is an
85-
instance of :class:`~packaging.tags.Tag`.
84+
a string for the rest of the build number. The tags portion is a
85+
frozen set of :class:`~packaging.tags.Tag` instances (as the tag
86+
string format allows multiple tags to be combined into a single
87+
string).
8688

8789
:param str filename: The name of the wheel file.
8890
:raises InvalidWheelFilename: If the filename in question

0 commit comments

Comments
 (0)