`no-redef` issued with package import but not with local import
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
I can type-annotate untyped imports from a local file, but not from a package (in which case I get a no-redef error).
To Reproduce
my_local.py
from funcy.decorators import decorator
@decorator
def retry(call, tries, errors=Exception, timeout=0, filter_errors=None):
pass
bug.py
from typing import Callable
# Works without error message
r1: Callable
from my_local import retry as r1
# pip install funcy
# Throws a no-redef error
r2: Callable
from funcy.flow import retry as r2
Expected Behavior
Same behavior (no error) in both cases.
Actual Behavior
my_local.py:1: error: Skipping analyzing "funcy.decorators": module is installed, but missing library stubs or py.typed marker [import]
my_local.py:5: error: Function is missing a type annotation [no-untyped-def]
bug.py:4: error: Missing type parameters for generic type "Callable" [type-arg]
bug.py:9: error: Missing type parameters for generic type "Callable" [type-arg]
bug.py:10: error: Skipping analyzing "funcy.flow": module is installed, but missing library stubs or py.typed marker [import]
bug.py:10: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
bug.py:10: error: Name "r2" already defined on line 9 [no-redef]
Found 6 errors in 2 files (checked 1 source file)
Your Environment
- Mypy version used: mypy 1.2.0 (compiled: yes)
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.11.2
Somewhat related: https://github.com/python/mypy/issues/13914
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostics using my_local.py and bug.py with the reported mypy and Python versions, then compare the local and package import paths. Trace how the two imports are analyzed and identify why only the package case produces no-redef; done means both examples behave consistently without that error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100