-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Can't redefine name imported from another module #591
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
Comments
(Another one related to #649.) |
I couldn't easily come up with an example that would fail, so I'm closing this. If some special case is still failing we can create a separate issue about that special case. |
#1168 was duped into this which had an example: try:
from zlip import decompress
except ImportError:
def decompress(val):
raise RuntimeError It's still a problem with mypy 1.15.0. Is there a different way we should be writing code that relies on types from maybe-available packages? |
Actually after commenting I see the case I'm running into is slightly different: try:
from rich.progress import TaskID
def foo(task_id: TaskID) -> None:
...
except ModuleNotFoundError:
def foo(task_id: int) -> None:
... Which yields "All conditional function variants must have identical signatures", which is the same error, but possibly not the same problem. |
It should be possible to redefine a name imported from another module, at least in stubs. Currently mypy complains about the redefinition (at least often). We can treat this as an assignment and just verify that the types are compatible.
The text was updated successfully, but these errors were encountered: