ruff
11449acf - Avoid marking `InitVar` as a typing-only annotation (#9688)

Commit
1 year ago
Avoid marking `InitVar` as a typing-only annotation (#9688) ## Summary Given: ```python from dataclasses import InitVar, dataclass @dataclass class C: i: int j: int = None database: InitVar[DatabaseType] = None def __post_init__(self, database): if self.j is None and database is not None: self.j = database.lookup('j') c = C(10, database=my_database) ``` We should avoid marking `InitVar` as typing-only, since it _is_ required by the dataclass at runtime. Note that by default, we _already_ don't flag this, since the `@dataclass` member is needed at runtime too -- so it's only a problem with `strict` mode. Closes https://github.com/astral-sh/ruff/issues/9666.
Author
Parents
Loading