Rule for missing members typing annotations
Consider the following class:
class Person:
name: str
def __init__(self, name: str, age: int) -> None:
self.name = name
self.age = age
The rule would suggests adding a typing annotation for Person.age so the code would look like this:
class Person:
name: str
age: int
def __init__(self, name: str, age: int) -> None:
self.name = name
self.age = age
Thanks. Such a rule does make sense to me but Ruff's current capabilities only allow this rule to provide precise results when the class has no base classes because it can't resolve attributes from other classes (at least not if they're defined in other files). This would make the rule less useful.
I'm not a fan of the extra boilerplate and bookkeeping personally.
Type-checkers already scan for assignments in __init__. And if you don't enable a rule to ensure that you don't forget to initialize, you may end up with extra declarations if you remove the member later.
@Avasam There could also be a rule for redundant type annotations that aren't used at all