Initial section

This commit is contained in:
David Peter 2025-12-13 11:19:46 +01:00
parent ef3d48ac4a
commit 6dc83fb2b2
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,39 @@
<!-- markdownlint-disable -->
# Type system features
This page summarizes the support for various type system features in ty.
## Dataclasses
[Official documentation](https://typing.python.org/en/latest/spec/dataclasses.html)
| Feature | Status |
| :-------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------- |
| `@dataclass` decorator (`init`, `repr`, `eq`, `order`, `frozen`, `match_args`, `kw_only`, `slots`, `weakref_slot`, `unsafe_hash`) | ✅ |
| `field()` (`default`, `default_factory`, `init`, `kw_only`, `doc`, `repr`, `hash`, `compare`) | ✅ |
| `InitVar[…]`, `ClassVar[…]` exclusion, `KW_ONLY` sentinel | ✅ |
| `fields()`, `__dataclass_fields__` | ✅ |
| `Final` fields | ✅ |
| Inheritance, generic dataclasses, descriptor-typed fields | ✅ |
| `replace()`, `__replace__` | ⚠️ `__replace__` works, `replace()` returns `Unknown` |
| `asdict()` | ⚠️ incorrectly accepts class objects |
| `astuple()` | ⚠️ not tested |
| `make_dataclass()`, `is_dataclass()` | ⚠️ not tested |
| Diagnostic: frozen dataclass inheriting from non-frozen | ⚠️ not tested |
| Diagnostic: non-default field after default field | ❌ [#111](https://github.com/astral-sh/ty/issues/111) |
| Diagnostic: `order=True` with custom comparison methods | ❌ [#111](https://github.com/astral-sh/ty/issues/111) |
| Diagnostic: `frozen=True` with `__setattr__`/`__delattr__` | ❌ [#111](https://github.com/astral-sh/ty/issues/111) |
| `__post_init__` signature validation | ❌ [#111](https://github.com/astral-sh/ty/issues/111) |
## `dataclass_transform`
[Official documentation](https://typing.python.org/en/latest/spec/dataclasses.html#dataclass-transform)
| Feature | Status |
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| Function-based, metaclass-based, base-class-based transformers | ✅ |
| `eq_default`, `order_default`, `kw_only_default` parameters | ✅ |
| `frozen_default` parameter | ⚠️ metaclass override not working |
| `field_specifiers` (`init`, `default`, `default_factory`, `factory`, `kw_only`, `alias`) | ✅ |
| `field_specifiers` (`converter`) | ❌ [#1327](https://github.com/astral-sh/ty/issues/1327) |

View file

@ -98,6 +98,7 @@ nav:
- Exit codes: reference/exit-codes.md
- Environment variables: reference/environment.md
- Editor settings: reference/editor-settings.md
- Type system features: reference/type-system-features.md
validation:
omitted_files: warn
absolute_links: warn