Skip to content

Commit 161e5a7

Browse files
authored
Merge branch 'main' into override-with-annotated
2 parents 7c98e50 + 01e2224 commit 161e5a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+721
-356
lines changed

.github/workflows/main.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ jobs:
1919

2020
steps:
2121
- uses: "actions/checkout@v4"
22+
with:
23+
persist-credentials: false
2224

2325
- uses: "pdm-project/setup-pdm@v4"
2426
with:
2527
python-version: "${{ matrix.python-version }}"
2628
allow-python-prereleases: true
2729
cache: true
28-
version: "2.19.2"
30+
version: "2.21.0"
2931

3032
- name: "Run Tox"
3133
run: |
@@ -48,6 +50,8 @@ jobs:
4850

4951
steps:
5052
- uses: "actions/checkout@v4"
53+
with:
54+
persist-credentials: false
5155

5256
- uses: "actions/setup-python@v5"
5357
with:
@@ -75,7 +79,7 @@ jobs:
7579
echo "total=$TOTAL" >> $GITHUB_ENV
7680
7781
# Report again and fail if under the threshold.
78-
python -Im coverage report --fail-under=99
82+
python -Im coverage report --fail-under=100
7983
8084
- name: "Upload HTML report."
8185
uses: "actions/upload-artifact@v4"
@@ -104,10 +108,12 @@ jobs:
104108

105109
steps:
106110
- uses: "actions/checkout@v4"
111+
with:
112+
persist-credentials: false
107113
- uses: "pdm-project/setup-pdm@v4"
108114
with:
109115
python-version: "3.12"
110-
version: "2.19.2"
116+
version: "2.21.0"
111117

112118
- name: "Install check-wheel-content and twine"
113119
run: "python -m pip install twine check-wheel-contents"

.github/workflows/pypi-package.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ on:
1010
- published
1111
workflow_dispatch:
1212

13-
permissions:
14-
contents: read
15-
id-token: write
16-
1713
jobs:
1814
build-package:
1915
name: Build & verify package
@@ -23,8 +19,9 @@ jobs:
2319
- uses: actions/checkout@v4
2420
with:
2521
fetch-depth: 0
22+
persist-credentials: false
2623

27-
- uses: hynek/build-and-inspect-python-package@v1
24+
- uses: hynek/build-and-inspect-python-package@v2
2825

2926
# Upload to Test PyPI on every commit on main.
3027
release-test-pypi:
@@ -33,10 +30,12 @@ jobs:
3330
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
3431
runs-on: ubuntu-latest
3532
needs: build-package
33+
permissions:
34+
id-token: write
3635

3736
steps:
3837
- name: Download packages built by build-and-inspect-python-package
39-
uses: actions/download-artifact@v3
38+
uses: actions/download-artifact@v4
4039
with:
4140
name: Packages
4241
path: dist
@@ -53,10 +52,12 @@ jobs:
5352
if: github.event.action == 'published'
5453
runs-on: ubuntu-latest
5554
needs: build-package
55+
permissions:
56+
id-token: write
5657

5758
steps:
5859
- name: Download packages built by build-and-inspect-python-package
59-
uses: actions/download-artifact@v3
60+
uses: actions/download-artifact@v4
6061
with:
6162
name: Packages
6263
path: dist

.github/workflows/zizmor.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Zizmor
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["*"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
zizmor:
14+
name: Zizmor latest via uv
15+
runs-on: ubuntu-latest
16+
permissions:
17+
security-events: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
24+
- name: Install the latest version of uv
25+
uses: astral-sh/setup-uv@v4
26+
with:
27+
version: "latest"
28+
- name: Run zizmor 🌈
29+
run: uvx zizmor --format sarif . > results.sarif
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Upload SARIF file
33+
uses: github/codeql-action/upload-sarif@v3
34+
with:
35+
# Path to SARIF file relative to the root of the repository
36+
sarif_file: results.sarif
37+
# Optional category for the results
38+
# Used to differentiate multiple results for one commit
39+
category: zizmor

HISTORY.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The third number is for emergencies when we need to start branches for older rel
1010
Our backwards-compatibility policy can be found [here](https://github.com/python-attrs/cattrs/blob/main/.github/SECURITY.md).
1111

1212

13-
## 24.2.0 (UNRELEASED)
13+
## 25.1.0 (UNRELEASED)
1414

1515
- **Potentially breaking**: The converters raise {class}`StructureHandlerNotFoundError` more eagerly (on hook creation, instead of on hook use).
1616
This helps surfacing problems with missing hooks sooner.
@@ -20,16 +20,20 @@ Our backwards-compatibility policy can be found [here](https://github.com/python
2020
([#577](https://github.com/python-attrs/cattrs/pull/577))
2121
- Expose {func}`cattrs.cols.mapping_unstructure_factory` through {mod}`cattrs.cols`.
2222
- Some `defaultdicts` are now [supported by default](https://catt.rs/en/latest/defaulthooks.html#defaultdicts), and
23-
{func}`cattrs.cols.is_defaultdict`{func} and `cattrs.cols.defaultdict_structure_factory` are exposed through {mod}`cattrs.cols`.
23+
{func}`cattrs.cols.is_defaultdict` and {func}`cattrs.cols.defaultdict_structure_factory` are exposed through {mod}`cattrs.cols`.
2424
([#519](https://github.com/python-attrs/cattrs/issues/519) [#588](https://github.com/python-attrs/cattrs/pull/588))
25+
- Generic PEP 695 type aliases are now supported.
26+
([#611](https://github.com/python-attrs/cattrs/issues/611) [#618](https://github.com/python-attrs/cattrs/pull/618))
2527
- Many preconf converters (_bson_, stdlib JSON, _cbor2_, _msgpack_, _msgspec_, _orjson_, _ujson_) skip unstructuring `int` and `str` enums,
2628
leaving them to the underlying libraries to handle with greater efficiency.
2729
([#598](https://github.com/python-attrs/cattrs/pull/598))
2830
- Literals containing enums are now unstructured properly, and their unstructuring is greatly optimized in the _bson_, stdlib JSON, _cbor2_, _msgpack_, _msgspec_, _orjson_ and _ujson_ preconf converters.
2931
([#598](https://github.com/python-attrs/cattrs/pull/598))
3032
- Preconf converters now handle dictionaries with literal keys properly.
3133
([#599](https://github.com/python-attrs/cattrs/pull/599))
32-
- Replace `cattrs.gen.MappingStructureFn` with `cattrs.SimpleStructureHook[In, T]`.
34+
- Structuring TypedDicts from invalid inputs now properly raises a {class}`ClassValidationError`.
35+
([#615](https://github.com/python-attrs/cattrs/issues/615) [#616](https://github.com/python-attrs/cattrs/pull/616))
36+
- Replace `cattrs.gen.MappingStructureFn` with {class}`cattrs.SimpleStructureHook`.
3337
- Python 3.13 is now supported.
3438
([#543](https://github.com/python-attrs/cattrs/pull/543) [#547](https://github.com/python-attrs/cattrs/issues/547))
3539
- Python 3.8 is no longer supported, as it is end-of-life. Use previous versions on this Python version.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ clean-test: ## remove test and coverage artifacts
4848
rm -fr htmlcov/
4949

5050
lint: ## check style with ruff and black
51-
pdm run ruff src/ tests bench
51+
pdm run ruff check src/ tests bench
5252
pdm run black --check src tests docs/conf.py
5353

5454
test: ## run tests quickly with the default Python

docs/defaulthooks.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ Generic TypedDicts work on Python 3.11 and later, since that is the first Python
333333

334334
[`typing.Required` and `typing.NotRequired`](https://peps.python.org/pep-0655/) are supported.
335335

336-
[Similar to _attrs_ classes](customizing.md#using-cattrsgen-generators), un/structuring can be customized using {meth}`cattrs.gen.typeddicts.make_dict_structure_fn` and {meth}`cattrs.gen.typeddicts.make_dict_unstructure_fn`.
336+
:::{caution}
337+
If `from __future__ import annotations` is used or if annotations are given as strings, `Required` and `NotRequired` are ignored by cattrs.
338+
See [note in the Python documentation](https://docs.python.org/3/library/typing.html#typing.TypedDict.__optional_keys__).
339+
:::
340+
341+
[Similar to _attrs_ classes](customizing.md#using-cattrsgen-hook-factories), un/structuring can be customized using {meth}`cattrs.gen.typeddicts.make_dict_structure_fn` and {meth}`cattrs.gen.typeddicts.make_dict_unstructure_fn`.
337342

338343
```{doctest}
339344
>>> from typing import TypedDict

0 commit comments

Comments
 (0)