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

Problem inheriting attribute from a generic and non-generic base class #2875

Closed
dmzkrsk opened this issue Feb 17, 2017 · 3 comments
Closed
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-inheritance Inheritance and incompatible overrides

Comments

@dmzkrsk
Copy link

dmzkrsk commented Feb 17, 2017

from typing import Generic, TypeVar, NamedTuple


T = TypeVar('T')


class Node(Generic[T]):
    v: T


class IntegerNode(Node[int], NamedTuple('IntegerNode', [('v', int)])):
    pass

Gives me an error:

11: error: Definition of "v" in base class "Node" is incompatible with definition in base class "IntegerNode@11"

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 24, 2017

Thanks for reporting this! This looks like a bug in mypy.

This is tangentially related to #685 but looks like a separate issue.

@pkch
Copy link
Contributor

pkch commented Apr 1, 2017

This is unrelated to NamedTuple:

class Base1(Generic[T]):
    v: T

class Base2:
    v: int

class C(Base1[int], Base2):  # error
    pass

The error is the same: : Definition of "v" in base class "Base1" is incompatible with definition in base class "Base2"

@JukkaL JukkaL changed the title Inheriting NamedTuple from Generic Problem inheriting attribute from a generic and non-generic base class Apr 3, 2017
@JukkaL JukkaL added the false-positive mypy gave an error on correct code label May 19, 2018
@AlexWaygood AlexWaygood added topic-inheritance Inheritance and incompatible overrides and removed topic-named-tuple labels Mar 27, 2022
@ilevkivskyi
Copy link
Member

This has been fixed recently, the example now passes on current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-1-normal topic-inheritance Inheritance and incompatible overrides
Projects
None yet
Development

No branches or pull requests

5 participants