You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve abstract classes through identity decorators - #11710
Preserve abstract-class instantiation diagnostics through proven identity decorators while allowing decorators that genuinely replace a class to return concrete results.
How you figured out what to do
I traced decorated class evaluation and abstract-use diagnostics through decorators.ts, typeEvaluator.ts, and the checker. A generic decorator returning type[T] obscured the original abstract class, but type signatures alone were insufficient because replacement decorators can have the same apparent shape.
Implementation
Record class identity preservation only when the applied decorator can be proven from its body and declarations to return its class argument unchanged. Recover the underlying class for abstract-use diagnostics only in that proven case; replacements, casts, reassignments, and function-decorated lookalikes retain existing behavior.
Screenshots or GIFs are not applicable because this change affects analyzer or language-service behavior and has no visual UI.
Testing
Added checker coverage and local/imported samples for abstract protocols and ABCs, stacked decorators, concrete implementations, replacement returns, casts, reassignments, and false-positive boundaries. A 565-test checker/evaluator selection passed.
Regression threshold: 20.0%
Statistic: median
Variance guard: >1.0s time and >100.0 MB memory
Package
Checker
Files checked
Time
Time delta
Peak memory
Memory delta
Status
ansible
pyright
583
18.219s
+1.4%
1082.0 MB
-0.5%
🟢 Pass
click
pyright
17
2.674s
+0.2%
355.0 MB
-0.1%
🟢 Pass
homeassistant
pyright
9850
78.149s
+0.0%
6060.9 MB
-0.4%
🟢 Pass
numpy
pyright
356
33.698s
+0.8%
1339.1 MB
-1.4%
🟢 Pass
pandas
pyright
1459
130.364s
-1.0%
3518.1 MB
-3.6%
🟢 Pass
pytest
pyright
243
12.422s
+0.6%
843.6 MB
-0.1%
🟢 Pass
requests
pyright
19
2.348s
-0.2%
342.7 MB
-1.0%
🟢 Pass
torch
pyright
2400
135.585s
-1.1%
4796.6 MB
-3.7%
🟢 Pass
transformers
pyright
2901
84.187s
-2.9%
4966.3 MB
-1.0%
🟢 Pass
Pyright stats
Package
Parsed/bound
Checked
Find
Read
Tokenize
Parse
Imports
Bind
Check
Cycles
ansible
989
583
0.040s
0.087s
0.390s
0.740s
0.203s
0.997s
14.713s
0.000s
click
111
17
0.000s
0.013s
0.103s
0.180s
0.030s
0.237s
1.817s
0.000s
homeassistant
11147
9850
0.213s
0.503s
1.767s
2.997s
1.360s
4.030s
65.750s
0.000s
numpy
603
356
0.010s
0.057s
0.343s
0.720s
0.250s
0.807s
30.937s
0.000s
pandas
1895
1459
0.060s
0.213s
1.140s
2.460s
0.283s
2.483s
123.190s
0.000s
pytest
542
243
0.020s
0.053s
0.347s
0.537s
0.110s
0.723s
10.210s
0.000s
requests
168
19
0.000s
0.017s
0.120s
0.223s
0.057s
0.267s
1.360s
0.000s
torch
3079
2400
0.140s
0.377s
2.010s
3.637s
0.597s
4.407s
122.887s
0.000s
transformers
3535
2901
0.060s
0.303s
1.497s
2.430s
0.670s
6.317s
74.093s
0.000s
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Preserve abstract-class instantiation diagnostics through proven identity decorators while allowing decorators that genuinely replace a class to return concrete results.
How you figured out what to do
I traced decorated class evaluation and abstract-use diagnostics through
decorators.ts,typeEvaluator.ts, and the checker. A generic decorator returningtype[T]obscured the original abstract class, but type signatures alone were insufficient because replacement decorators can have the same apparent shape.Implementation
Record class identity preservation only when the applied decorator can be proven from its body and declarations to return its class argument unchanged. Recover the underlying class for abstract-use diagnostics only in that proven case; replacements, casts, reassignments, and function-decorated lookalikes retain existing behavior.
Screenshots or GIFs are not applicable because this change affects analyzer or language-service behavior and has no visual UI.
Testing
Added checker coverage and local/imported samples for abstract protocols and ABCs, stacked decorators, concrete implementations, replacement returns, casts, reassignments, and false-positive boundaries. A 565-test checker/evaluator selection passed.
Addresses
Fixes #11411