We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug Report
Mypy raises errors indicating the absence of attributes for objects of type "None" when using any() or all().
any()
all()
To Reproduce
from dataclasses import dataclass def get_hobby_description(hobby: str) -> ...: ... def get_best_friend_info(best_friend: str) -> ...: ... @dataclass class Person: name: str age: int hobby: str | None = None best_friend: str | None = None person = Person(name="name", age=0, hobby=None, best_friend=None) if not all((person.hobby, person.best_friend)): raise ValueError if not any((person.hobby, person.best_friend)): raise ValueError hobby_description = get_hobby_description(person.hobby) best_friend_info = get_best_friend_info(person.best_friend)
Expected Behavior
The code should be recognized as correct since it checks for the absence of None among the variables person.hobby and person.best_friend.
None
person.hobby
person.best_friend
Actual Behavior
error: Argument 1 to "get_hobby_description" has incompatible type "str | None"; expected "str" [arg-type] error: Argument 1 to "get_best_friend_info" has incompatible type "str | None"; expected "str" [arg-type]
Your Environment
mypy.ini
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug Report
Mypy raises errors indicating the absence of attributes for objects of type "None" when using
any()
orall()
.To Reproduce
Expected Behavior
The code should be recognized as correct since it checks for the absence of
None
among the variablesperson.hobby
andperson.best_friend
.Actual Behavior
Mypy raises errors indicating the absence of attributes for objects of type "None" when using
any()
orall()
.Your Environment
mypy.ini
(and other config files): NoThe text was updated successfully, but these errors were encountered: