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

Open
@bersbersbers

Description

@bersbersbers

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions