KEMBAR78
MyPy not acknowledging __all__ · Issue #1606 · python/mypy · GitHub
Skip to content

MyPy not acknowledging __all__  #1606

@TimSimpsonR

Description

@TimSimpsonR

When MyPy encounters star (*) imports it considers every symbol defined in the given module as being imported even if an __all__ attribute is present on the module.

For example, say you have mypkg with two files, main.py:

from datetime import datetime
from mypkg.widgets import *

and widget.py:

from datetime import datetime

__all__ = [
    "Gadget"
]

class Gadget(object):
    pass

Running "mypy mypkg/app.py" issues the following error: "mypkg/app.py:2: error: Name 'datetime' already defined", though datetime should not be re-imported to the app module.

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