Guido van Rossum <gu...@python.org> added the comment:

Thanks Евгений Махмудов for the report!

The crux is this:

class A(NamedTuple):
    value: bool = True

class B(A):
    value: bool = False

B(True).value  # Expected True, but is False
B(True)[0]  # True as expected

If we add NamedTuple to B's bases or make its metaclass NamedTupleMeta, it 
works as expected.

Introspecting the classes a bit more suggests a cause: the class variable 
A.value is a <property ...>, but B.value is just False, and adding the extra 
base class or metaclass corrects this.

Ivan, you can probably tell what's wrong from this.  Maybe it's hard to fix, 
because NamedTuple doesn't appear in A.__mro__?  (IIRC there was a question 
about that somewhere recently too?)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33077>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to