Skip to content

Use of star-imports nearly always yields "name already defined" errors #2135

@davidfstr

Description

@davidfstr

If I have a module with star imports, such as:

# A.py
from B import *
from C import *

It is very common to get "name already defined" errors on one of the star-import lines:

$ mypy A.py
A.py:2: error: Name 'Boom' already defined

In this example, the related files are:

# B.py
from D import Boom

# C.py
from D import Boom

# D.py
class Boom:
    pass

Currently I use "# type: ignore" on pretty much all star-imports due to these "name already defined" errors.

Assuming this is a real issue that hasn't already been reported elsewhere, I'm planning to use its issue URL as a reference to justify the use of "# type: ignore".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions