-
Notifications
You must be signed in to change notification settings - Fork 29
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
_Attrib
type is not comparable to dict[str, str]
even though it works at runtime
#98
Comments
It's sometimes difficult to completely map lxml's pythonic API to static type annotations. PR welcome. |
i think the fix is to add a class object:
def __eq__(self, __value: object) -> bool: ...
class _Attrib:
def __eq__(self, other: _Attrib | _DictAnyStr) -> bool: ... # error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object" (i proposed a solution in KotlinIsland/basedmypy#574 (comment) but i'm sure that would break lots of existing code) |
Well, it obviously has an I don't really see why we should be specific about the things that |
On the contrary, this is perfectly covered by the typing system. If If we want to create a type error for the user, then we could use overloads to be a bit smarter about it:
In this case, if the user compares with anything that is not a compatible mapping, then a type checker like mypy can produce an error saying that the comparison is redundant, as it will always return False. |
mypy complains about this code, even though it works at runtime:
The text was updated successfully, but these errors were encountered: