-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Description
Starting in ty version 0.0.17 errors started popping up for instance attributes that start out as "None" and are assigned later.
class Test:
def __init__(self):
self.xxx = None
self.fn_1()
self.fn_2()
def fn_1(self) -> None:
self.xxx = 'populated'
def fn_2(self) -> None:
print(self.xxx.strip()) # <- Error if "unresolved-attribute" is enabled
# If "unresolved-attribute" is disabled, I won't see this real error
yyy = 1
print(yyy.strip())I know it's possible to avoid these errors by performing a if self.xxx: check before using self.xxx, but for some scripts that involves littering the code with if self.xxx: checks, for little added value. It would be nice to have a rule to control this. Pyright has configuration flags such as "reportOptionalMemberAccess" to allow for this behavior, and mypy has "strict_optional".
EDIT - Is this supposed to be handled by ignoring possibly-missing-attribute? That doesn't seem to be ignoring these errors in version 0.0.17.
Still loving using ty, and appreciate all your hard work!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels