Closed as not planned
Description
Minimal repro:
import attrs
@attrs.define
class Bar[K, V]:
key: K
value: V
y = Bar[str, int]("hello", 123)
get_args(y.__orig_class__) # AttributeError: 'Bar' object has no attribute '__orig_class__'
This is not due to using PEP-695, as verified below:
import attrs
from typing import TypeVar, Generic
K = TypeVar("K")
V = TypeVar("V")
@attrs.define
class Bar(Generic[K, V]):
key: K
value: V
y = Bar[str, int]("hello", 123)
get_args(y.__orig_class__) # AttributeError: 'Bar' object has no attribute '__orig_class__'
Variations that work:
import attrs
@attrs.define(slots=False)
class Bar[K, V]:
key: K
value: V
y = Bar[str, int]("hello", 123)
get_args(y.__orig_class__) # (str, int)
import dataclasses
@dataclasses.dataclass
class Bar[K, V]:
key: K
value: V
y = Bar[str, int]("hello", 123)
get_args(y.__orig_class__) # (str, int)
Metadata
Metadata
Assignees
Labels
No labels