Skip to content
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

redefined-outer-name is very commonly emitted when using the TYPE_CHECKING feature #2834

Closed
NeilGirdhar opened this issue Mar 25, 2019 · 1 comment
Labels

Comments

@NeilGirdhar
Copy link

This is a common pattern when annotating using types that cannot be imported:

from __future__ import annotations
from typing import TYPE_CHECKING


class X:

    def f(self, s: Signal):
        # This import makes the definition work.
        from .signal import Signal
        t = Signal("blah")


if TYPE_CHECKING:
    # This import makes the annotations work.
    from .signal import Signal

Unfortunately, this gives

Redefining name 'Signal' from outer scope (line 10) (redefined-outer-name)

The import may not be possible to do at the top of the file because of circular imports. Perhaps two imports that are from the same place should not produce this error.

@PCManticore
Copy link
Contributor

Thank you @NeilGirdhar This makes sense.

mscuthbert added a commit to cuthbertLab/music21 that referenced this issue Sep 24, 2022
The fix in pylint-dev/pylint#2834 does not seem to be working here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants