Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# History

## 23.2.1 (UNRELEASED)

- Fix unnecessary `typing_extensions` import on Python 3.11.
([#446](https://github.com/python-attrs/cattrs/issues/446) [#447](https://github.com/python-attrs/cattrs/pull/447))

## 23.2.0 (2023-11-17)

- **Potentially breaking**: skip _attrs_ fields marked as `init=False` by default. This change is potentially breaking for unstructuring.
Expand Down
14 changes: 13 additions & 1 deletion src/cattrs/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
from attrs import fields as attrs_fields
from attrs import resolve_types

__all__ = ["ExceptionGroup", "ExtensionsTypedDict", "TypedDict", "is_typeddict"]
__all__ = [
"ExceptionGroup",
"ExtensionsTypedDict",
"TypedDict",
"TypeAlias",
"is_typeddict",
]

try:
from typing_extensions import TypedDict as ExtensionsTypedDict
Expand All @@ -39,6 +45,12 @@
assert sys.version_info >= (3, 10)
from typing import is_typeddict as _is_typeddict

try:
from typing_extensions import TypeAlias
except ImportError:
assert sys.version_info >= (3, 11)
from typing import TypeAlias


def is_typeddict(cls):
"""Thin wrapper around typing(_extensions).is_typeddict"""
Expand Down
3 changes: 2 additions & 1 deletion src/cattrs/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from typing import Any, Callable, Dict, Generic, List, Optional, Tuple, TypeVar, Union

from attrs import Factory, define, field
from typing_extensions import TypeAlias

from cattrs._compat import TypeAlias

T = TypeVar("T")

Expand Down