-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamline Attribute.__get__ type stubs #578
base: master
Are you sure you want to change the base?
Conversation
def is_type_safe(self, key: Any, value: Any) -> bool: ... | ||
def validate(self) -> bool: ... | ||
|
||
class ListAttribute(Generic[_T], Attribute[List[_T]]): | ||
class ListAttribute(Generic[_MT], Attribute[List[_MT]]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ListAttribute's of
argument is restricted to MapAttribute-based types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, that's true only if of is not None
, otherwise every element of ListAttribute can be either a number, a string, a MapAttribute, etc. but we cannot really express it in type stubs alone :(
cc @garrettheel |
We can use the fact that
Attribute[_T]
is a generic class to DRY__get__
.