8000 New semantic analyzer: fix daemon crash and performance regression (#… · python/mypy@466bff8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 466bff8

Browse files
authored
New semantic analyzer: fix daemon crash and performance regression (#6836)
Some attribute patches weren't applied after stripping a class. This could result in crashes when stripping, as an expected attribute wasn't included in the symbol table. It also resulted in unnecessary work, as the attributes would be added back by triggering the methods the define the attribute. Fixes #6834.
1 parent 4cf0471 commit 466bff8

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

mypy/server/update.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,8 @@ def key(node: FineGrainedDeferredNode) -> int:
950950
if not manager.options.new_semantic_analyzer:
951951
strip_target(deferred.node)
952952
else:
953-
patches = strip_target_new(deferred.node)
953+
new_patches = strip_target_new(deferred.node)
954+
patches.extend(new_patches)
954955
if not options.new_semantic_analyzer:
955956
re_analyze_nodes(file_node, nodes, manager, options)
956957
else:

test-data/unit/fine-grained.test

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8815,3 +8815,33 @@ B().x
88158815
[out]
88168816
==
88178817
==
8818+
8819+
[case testNewSemanticAnalyzerUpdateMethodAndClass]
8820+
# flags: --new-semantic-analyzer
8821+
import m
8822+
8823+
m.x
8824+
8825+
class A:
8826+
def f(self) -> None:
8827+
self.x = 0
8828+
m.y
8829+
8830+
def g(self) -> None:
8831+
m.x
8832+
8833+
[file m.py]
8834+
x = 0
8835+
y = 0
8836+
8837+
[file m.py.2]
8838+
x = ''
8839+
y = 0
8840+
8841+
[file m.py.3]
8842+
x = ''
8843+
y = ''
8844+
8845+
[out]
8846+
==
8847+
==

0 commit comments

Comments
 (0)
0