|
3 | 3 | from __future__ import annotations
|
4 | 4 |
|
5 | 5 | from typing import Any, Final, FrozenSet, Literal, TypedDict
|
6 |
| - |
7 | 6 | from typing_extensions import NotRequired
|
8 | 7 |
|
9 | 8 | from mypy.nodes import (
|
|
33 | 32 | from mypy.types import FINAL_DECORATOR_NAMES
|
34 | 33 | from mypyc.errors import Errors
|
35 | 34 |
|
36 |
| -MYPYC_ATTRS: Final[FrozenSet["MypycAttr"]] = frozenset(["native_class", "allow_interpreted_subclasses", "serializable"]) |
| 35 | +MYPYC_ATTRS: Final[FrozenSet[MypycAttr]] = frozenset( |
| 36 | + ["native_class", "allow_interpreted_subclasses", "serializable"] |
| 37 | +) |
37 | 38 |
|
38 | 39 | DATACLASS_DECORATORS: Final = frozenset(["dataclasses.dataclass", "attr.s", "attr.attrs"])
|
39 | 40 |
|
40 | 41 |
|
41 | 42 | MypycAttr = Literal["native_class", "allow_interpreted_subclasses", "serializable"]
|
42 | 43 |
|
| 44 | + |
43 | 45 | class MypycAttrs(TypedDict):
|
44 | 46 | native_class: NotRequired[bool]
|
45 | 47 | allow_interpreted_subclasses: NotRequired[bool]
|
@@ -124,11 +126,9 @@ def get_mypyc_attr_call(d: Expression) -> CallExpr | None:
|
124 | 126 | return d
|
125 | 127 | return None
|
126 | 128 |
|
127 |
| - |
| 129 | + |
128 | 130 | def get_mypyc_attrs(
|
129 |
| - stmt: ClassDef | Decorator, |
130 |
| - path: str, |
131 |
| - errors: Errors, |
| 131 | + stmt: ClassDef | Decorator, path: str, errors: Errors |
132 | 132 | ) -> tuple[MypycAttrs, dict[MypycAttr, int]]:
|
133 | 133 | """Collect all the mypyc_attr attributes on a class definition or a function."""
|
134 | 134 | attrs: MypycAttrs = {}
|
|
0 commit comments