Thanks to visit codestin.com
Credit goes to github.com

Skip to content

no-redef issued with package import but not with local import #15170

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

Open
bersbersbers opened this issue May 2, 2023 · 1 comment
Open

no-redef issued with package import but not with local import #15170

bersbersbers opened this issue May 2, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@bersbersbers
Copy link

bersbersbers commented May 2, 2023

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: #13914

@bersbersbers bersbersbers added the bug mypy got something wrong label May 2, 2023
@bersbersbers
Copy link
Author

Some additional details can be found in https://stackoverflow.com/q/76152464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant