You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive bad-argument-type when calling a method with AnyStr #2644
from typing import AnyStr
class A:
@classmethod
def create(cls, x: AnyStr | None): ...
def test(x: AnyStr | None):
A.create(x)
Output:
ERROR Argument `AnyStr | None` is not assignable to parameter `x` with type `str | None` in function `A.create` [bad-argument-type]
--> /tmp/foo.py:10:12
|
10 | A.create(x)
It looks like AnyStr is specialized to str? Possibly a duplicate of #2370.
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
This appears to be related to #105? it looks like we are pinning the typevar that has type AnyStr to str. So to fundamentally solve this, I think issue 105 would have to be solved first. So this is blocked by the pinning issue. cc @rchen152 in case there is an alternative thought.
@migeed-z Might worth checking what type we're passing in to create in the A.create(x) call - it's possible that we're not handling AnyStr correctly there. But if we are, then yeah, the str | None in the error message suggests that we're probably pinning AnyStr to the wrong type.
This issue has someone assigned, but has not had recent activity for more than 2 weeks.
If you are still working on this issue, please add a comment so everyone knows. Otherwise, please unassign yourself and allow someone else to take over.
Activity
migeed-z commentedon Mar 19, 2026
This appears to be related to #105? it looks like we are pinning the typevar that has type
AnyStrtostr. So to fundamentally solve this, I think issue 105 would have to be solved first. So this is blocked by the pinning issue. cc @rchen152 in case there is an alternative thought.rchen152 commentedon Mar 20, 2026
@migeed-z Might worth checking what type we're passing in to
createin theA.create(x)call - it's possible that we're not handlingAnyStrcorrectly there. But if we are, then yeah, thestr | Nonein the error message suggests that we're probably pinningAnyStrto the wrong type.Avoid pinning solver variables too early when RHS is a union
Avoid pinning solver variables too early when RHS is a union (faceboo…
Avoid pinning solver variables too early when RHS is a union (faceboo…
Avoid pinning solver variables too early when RHS is a union (faceboo…
Avoid pinning solver variables too early when RHS is a union (faceboo…
Avoid pinning solver variables too early when RHS is a union (faceboo…
github-actions commentedon Apr 10, 2026
This issue has someone assigned, but has not had recent activity for more than 2 weeks.
If you are still working on this issue, please add a comment so everyone knows. Otherwise, please unassign yourself and allow someone else to take over.
Thank you for your contributions!
Restore var state after failed Quantified checks in is_subset_eq