Skip to content

Invalid undefined variable errors (mypy not considering __all__?) #451

Closed
@refi64

Description

@refi64

Sample:

from abc import abstractmethod
from typing import *

T = typevar('T')

class Rnd(Protocol[T]):
    @abstractmethod
    def some_method(x: T) -> T:
        pass

That gives:

err.py, line 2: Name 'T' already defined
err.py, line 2: Name 'abstractmethod' already defined
err.py, line 6: Name 'Protocol' is not defined

Removing the top line solves the second error, but it obviously doesn't run under Python 3:

Traceback (most recent call last):
  File "err.py", line 6, in <module>
    class Rnd(Protocol[T]):
  File "err.py", line 7, in Rnd
    @abstractmethod
NameError: name 'abstractmethod' is not defined

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