Skip to content

Commit d987382

Browse files
authored
Update attrs and use attrs.NothingType (#622)
1 parent 01e2224 commit d987382

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

pdm.lock

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ test = [
1111
"pytest>=8.3.2",
1212
"pytest-benchmark>=4.0.0",
1313
"immutables>=0.20",
14-
"typing-extensions>=4.7.1",
1514
"coverage>=7.6.1",
1615
"pytest-xdist>=3.6.1",
1716
]
@@ -22,7 +21,6 @@ docs = [
2221
"myst-parser>=1.0.0",
2322
"pendulum>=2.1.2",
2423
"sphinx-autobuild",
25-
"typing-extensions>=4.8.0",
2624
]
2725
bench = [
2826
"pyperf>=2.6.1",
@@ -42,7 +40,7 @@ authors = [
4240
{name = "Tin Tvrtkovic", email = "[email protected]"},
4341
]
4442
dependencies = [
45-
"attrs>=23.1.0",
43+
"attrs>=24.3.0",
4644
"typing-extensions>=4.12.2",
4745
"exceptiongroup>=1.1.1; python_version < '3.11'",
4846
]

src/cattrs/_compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from typing import Sequence as TypingSequence
4343
from typing import Set as TypingSet
4444

45-
from attrs import NOTHING, Attribute, Factory, resolve_types
45+
from attrs import NOTHING, Attribute, Factory, NothingType, resolve_types
4646
from attrs import fields as attrs_fields
4747
from attrs import fields_dict as attrs_fields_dict
4848

@@ -296,7 +296,7 @@ def get_newtype_base(typ: Any) -> Optional[type]:
296296
return None
297297

298298

299-
def get_notrequired_base(type) -> "Union[Any, Literal[NOTHING]]":
299+
def get_notrequired_base(type) -> Union[Any, NothingType]:
300300
if is_annotated(type):
301301
# Handle `Annotated[NotRequired[int]]`
302302
type = get_args(type)[0]

src/cattrs/cols.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from collections import defaultdict
6-
from collections.abc import Iterable
6+
from collections.abc import Callable, Iterable
77
from functools import partial
88
from typing import (
99
TYPE_CHECKING,
@@ -15,7 +15,7 @@
1515
get_type_hints,
1616
)
1717

18-
from attrs import NOTHING, Attribute
18+
from attrs import NOTHING, Attribute, NothingType
1919

2020
from ._compat import (
2121
ANIES,
@@ -294,7 +294,9 @@ def is_defaultdict(type: Any) -> bool:
294294

295295

296296
def defaultdict_structure_factory(
297-
type: type[defaultdict], converter: BaseConverter, default_factory: Any = NOTHING
297+
type: type[defaultdict],
298+
converter: BaseConverter,
299+
default_factory: Callable[[], Any] | NothingType = NOTHING,
298300
) -> StructureHook:
299301
"""A structure hook factory for defaultdicts.
300302

src/cattrs/strategies/_unions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections import defaultdict
2-
from typing import Any, Callable, Literal, Union
2+
from typing import Any, Callable, Union
33

4-
from attrs import NOTHING
4+
from attrs import NOTHING, NothingType
55

66
from cattrs import BaseConverter
77
from cattrs._compat import get_newtype_base, is_literal, is_subclass, is_union_type
@@ -23,7 +23,7 @@ def configure_tagged_union(
2323
converter: BaseConverter,
2424
tag_generator: Callable[[type], str] = default_tag_generator,
2525
tag_name: str = "_type",
26-
default: Union[type, Literal[NOTHING]] = NOTHING,
26+
default: Union[type, NothingType] = NOTHING,
2727
) -> None:
2828
"""
2929
Configure the converter so that `union` (which should be a union) is

0 commit comments

Comments
 (0)