Skip to content

Commit 0f8385b

Browse files
authored
fine-grained: strip is_abstract (#4820)
Fixes a crash bug
1 parent 8100581 commit 0f8385b

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

mypy/server/aststrip.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def visit_class_def(self, node: ClassDef) -> None:
9292
def strip_type_info(self, info: TypeInfo) -> None:
9393
info.type_vars = []
9494
info.bases = []
95+
info.is_abstract = False
9596
info.abstract_attributes = []
9697
info.mro = []
9798
info.add_type_vars()

test-data/unit/fine-grained.test

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,6 +4249,54 @@ class g(Generic[T]):
42494249
==
42504250
a.py:2: error: Incompatible types in assignment (expression has type "g[int]", variable has type "int")
42514251

4252+
[case testMakeClassNoLongerAbstract1]
4253+
[file z.py]
4254+
from abc import abstractmethod, ABCMeta
4255+
class I(metaclass=ABCMeta):
4256+
@abstractmethod
4257+
def f(self) -> None: pass
4258+
[file b.py]
4259+
from z import I
4260+
class Foo(I):
4261+
pass
4262+
def x() -> Foo: return None
4263+
[file z.py.2]
4264+
from abc import abstractmethod, ABCMeta
4265+
class I(metaclass=ABCMeta):
4266+
pass
4267+
[file b.py.2]
4268+
from z import I
4269+
class Foo(I):
4270+
pass
4271+
def x() -> Foo: return Foo()
4272+
[out]
4273+
==
4274+
4275+
[case testMakeClassNoLongerAbstract2]
4276+
-- this version never failed, but it is just a file-renaming
4277+
-- away from the above test that did
4278+
[file a.py]
4279+
from abc import abstractmethod, ABCMeta
4280+
class I(metaclass=ABCMeta):
4281+
@abstractmethod
4282+
def f(self) -> None: pass
4283+
[file b.py]
4284+
from a import I
4285+
class Foo(I):
4286+
pass
4287+
def x() -> Foo: return None
4288+
[file a.py.2]
4289+
from abc import abstractmethod, ABCMeta
4290+
class I(metaclass=ABCMeta):
4291+
pass
4292+
[file b.py.2]
4293+
from a import I
4294+
class Foo(I):
4295+
pass
4296+
def x() -> Foo: return Foo()
4297+
[out]
4298+
==
4299+
42524300
[case testRefreshClassBasedEnum]
42534301
import aa
42544302
[file aa.py]

0 commit comments

Comments
 (0)