[ty] Conditionally defined dataclass fields by sharkdp · Pull Request #19197 · astral-sh/ruff (original) (raw)
In a situation like the following, there is not just one declaration of x. There's also an implicit x: <undefined> declaration at the start of the C scope. Both of them are visible at the end of the scope. The previous check here was filtering out all fields that had declarations that were <undefined>.
@dataclass class C: if flag: x: int