Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mypyc/irbuild/classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ def populate_non_ext_bases(builder: IRBuilder, cdef: ClassDef) -> Value:
for cls in cdef.info.mro[1:]:
if cls.fullname == 'builtins.object':
continue
if is_named_tuple and cls.fullname in ('typing.Sequence', 'typing.Iterable'):
if is_named_tuple and cls.fullname in ('typing.Sequence',
'typing.Iterable',
'typing.Collection',
'typing.Reversible',
'typing.Container'):
# HAX: Synthesized base classes added by mypy don't exist at runtime, so skip them.
# This could break if they were added explicitly, though...
continue
Expand Down
7 changes: 7 additions & 0 deletions mypyc/test-data/commandline.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ for x in [a, b, p, p.q]:
import b
import c
from p import s
from typing import NamedTuple

print('<a>', ord('A') == 65) # Test full builtins

Expand All @@ -42,6 +43,11 @@ print('<a>', f(5).x)
print('<c>', c.foo())
assert s.bar(10) == 20

class NT(NamedTuple):
x: int

print(NT(2))

[file b.py]
import a
import p.q
Expand Down Expand Up @@ -79,6 +85,7 @@ def bar(x: int) -> int:
<a> True
<a> 5
<c> 10
NT(x=2)
<main> 16

-- This test is here so we can turn it on when we get nervous about
Expand Down