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

Inheriting class with __slots__ defined #8358

Open
dhalenok opened this issue Feb 2, 2020 · 2 comments
Open

Inheriting class with __slots__ defined #8358

dhalenok opened this issue Feb 2, 2020 · 2 comments

Comments

@dhalenok
Copy link
Contributor

dhalenok commented Feb 2, 2020

  • Are you reporting a bug, or opening a feature request?

Feature request

  • Please insert below the code you are checking with mypy.
class Base():
    __slots__: List[str] = ['foo', 'bar']
    if TYPE_CHECKING:
        foo: int
        bar: int

class Derived(Base):
    __slots__: List[str] = ['bar']
  • What is the actual behavior/output?

Success: no issues found in 1 source file

  • What is the behavior/output you expect?

I believe it would be nice if mypy generated an error on __slots__ declaration in Derived class because 'bar' slot was already declared in Base class.

  • What are the versions of mypy and Python you are using?

Python 3.8.0, mypy 0.761

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 4, 2020

The redundant slot definition seems to work at runtime, so this seems pretty low priority.

@dhalenok
Copy link
Contributor Author

dhalenok commented Feb 4, 2020

@JukkaL Agree. On a side note, having the redundant slot wastes some memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants