Skip to content

Commit 2692cbe

Browse files
authored
Fix typing for assigned_stmts (#1377)
* Methods are attributes of the class and should therefore be typed as ClassVar
1 parent 7f444d5 commit 2692cbe

File tree

1 file changed

+54
-39
lines changed

1 file changed

+54
-39
lines changed

astroid/nodes/node_classes.py

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,16 @@
4444
import typing
4545
import warnings
4646
from functools import lru_cache
47-
from typing import TYPE_CHECKING, Any, Callable, Generator, Optional, TypeVar, Union
47+
from typing import (
48+
TYPE_CHECKING,
49+
Any,
50+
Callable,
51+
ClassVar,
52+
Generator,
53+
Optional,
54+
TypeVar,
55+
Union,
56+
)
4857

4958
from astroid import decorators, mixins, util
5059
from astroid.bases import Instance, _infer_stmts
@@ -478,7 +487,7 @@ def __init__(
478487
parent=parent,
479488
)
480489

481-
assigned_stmts: AssignedStmtsCall["AssignName"]
490+
assigned_stmts: ClassVar[AssignedStmtsCall["AssignName"]]
482491
"""Returns the assigned statement (non inferred) according to the assignment type.
483492
See astroid/protocols.py for actual implementation.
484493
"""
@@ -804,7 +813,7 @@ def postinit(
804813
if type_comment_posonlyargs is not None:
805814
self.type_comment_posonlyargs = type_comment_posonlyargs
806815

807-
assigned_stmts: AssignedStmtsCall["Arguments"]
816+
assigned_stmts: ClassVar[AssignedStmtsCall["Arguments"]]
808817
"""Returns the assigned statement (non inferred) according to the assignment type.
809818
See astroid/protocols.py for actual implementation.
810819
"""
@@ -1062,7 +1071,7 @@ def postinit(self, expr: Optional[NodeNG] = None) -> None:
10621071
"""
10631072
self.expr = expr
10641073

1065-
assigned_stmts: AssignedStmtsCall["AssignAttr"]
1074+
assigned_stmts: ClassVar[AssignedStmtsCall["AssignAttr"]]
10661075
"""Returns the assigned statement (non inferred) according to the assignment type.
10671076
See astroid/protocols.py for actual implementation.
10681077
"""
@@ -1210,7 +1219,7 @@ def postinit(
12101219
self.value = value
12111220
self.type_annotation = type_annotation
12121221

1213-
assigned_stmts: AssignedStmtsCall["Assign"]
1222+
assigned_stmts: ClassVar[AssignedStmtsCall["Assign"]]
12141223
"""Returns the assigned statement (non inferred) according to the assignment type.
12151224
See astroid/protocols.py for actual implementation.
12161225
"""
@@ -1307,7 +1316,7 @@ def postinit(
13071316
self.value = value
13081317
self.simple = simple
13091318

1310-
assigned_stmts: AssignedStmtsCall["AnnAssign"]
1319+
assigned_stmts: ClassVar[AssignedStmtsCall["AnnAssign"]]
13111320
"""Returns the assigned statement (non inferred) according to the assignment type.
13121321
See astroid/protocols.py for actual implementation.
13131322
"""
@@ -1393,7 +1402,7 @@ def postinit(
13931402
self.target = target
13941403
self.value = value
13951404

1396-
assigned_stmts: AssignedStmtsCall["AugAssign"]
1405+
assigned_stmts: ClassVar[AssignedStmtsCall["AugAssign"]]
13971406
"""Returns the assigned statement (non inferred) according to the assignment type.
13981407
See astroid/protocols.py for actual implementation.
13991408
"""
@@ -1864,7 +1873,7 @@ def postinit(
18641873
self.ifs = ifs
18651874
self.is_async = is_async
18661875

1867-
assigned_stmts: AssignedStmtsCall["Comprehension"]
1876+
assigned_stmts: ClassVar[AssignedStmtsCall["Comprehension"]]
18681877
"""Returns the assigned statement (non inferred) according to the assignment type.
18691878
See astroid/protocols.py for actual implementation.
18701879
"""
@@ -2556,7 +2565,7 @@ def __init__(
25562565
parent=parent,
25572566
)
25582567

2559-
assigned_stmts: AssignedStmtsCall["ExceptHandler"]
2568+
assigned_stmts: ClassVar[AssignedStmtsCall["ExceptHandler"]]
25602569
"""Returns the assigned statement (non inferred) according to the assignment type.
25612570
See astroid/protocols.py for actual implementation.
25622571
"""
@@ -2719,7 +2728,7 @@ def postinit(
27192728
self.orelse = orelse
27202729
self.type_annotation = type_annotation
27212730

2722-
assigned_stmts: AssignedStmtsCall["For"]
2731+
assigned_stmts: ClassVar[AssignedStmtsCall["For"]]
27232732
"""Returns the assigned statement (non inferred) according to the assignment type.
27242733
See astroid/protocols.py for actual implementation.
27252734
"""
@@ -3424,7 +3433,7 @@ def __init__(
34243433
parent=parent,
34253434
)
34263435

3427-
assigned_stmts: AssignedStmtsCall["List"]
3436+
assigned_stmts: ClassVar[AssignedStmtsCall["List"]]
34283437
"""Returns the assigned statement (non inferred) according to the assignment type.
34293438
See astroid/protocols.py for actual implementation.
34303439
"""
@@ -3855,7 +3864,7 @@ def postinit(self, value: Optional[NodeNG] = None) -> None:
38553864
"""
38563865
self.value = value
38573866

3858-
assigned_stmts: AssignedStmtsCall["Starred"]
3867+
assigned_stmts: ClassVar[AssignedStmtsCall["Starred"]]
38593868
"""Returns the assigned statement (non inferred) according to the assignment type.
38603869
See astroid/protocols.py for actual implementation.
38613870
"""
@@ -4186,7 +4195,7 @@ def __init__(
41864195
parent=parent,
41874196
)
41884197

4189-
assigned_stmts: AssignedStmtsCall["Tuple"]
4198+
assigned_stmts: ClassVar[AssignedStmtsCall["Tuple"]]
41904199
"""Returns the assigned statement (non inferred) according to the assignment type.
41914200
See astroid/protocols.py for actual implementation.
41924201
"""
@@ -4485,7 +4494,7 @@ def postinit(
44854494
self.body = body
44864495
self.type_annotation = type_annotation
44874496

4488-
assigned_stmts: AssignedStmtsCall["With"]
4497+
assigned_stmts: ClassVar[AssignedStmtsCall["With"]]
44894498
"""Returns the assigned statement (non inferred) according to the assignment type.
44904499
See astroid/protocols.py for actual implementation.
44914500
"""
@@ -4793,7 +4802,7 @@ def postinit(self, target: NodeNG, value: NodeNG) -> None:
47934802
self.target = target
47944803
self.value = value
47954804

4796-
assigned_stmts: AssignedStmtsCall["NamedExpr"]
4805+
assigned_stmts: ClassVar[AssignedStmtsCall["NamedExpr"]]
47974806
"""Returns the assigned statement (non inferred) according to the assignment type.
47984807
See astroid/protocols.py for actual implementation.
47994808
"""
@@ -5160,14 +5169,16 @@ def postinit(
51605169
self.patterns = patterns
51615170
self.rest = rest
51625171

5163-
assigned_stmts: Callable[
5164-
[
5165-
"MatchMapping",
5166-
AssignName,
5167-
Optional[InferenceContext],
5168-
Literal[None],
5169-
],
5170-
Generator[NodeNG, None, None],
5172+
assigned_stmts: ClassVar[
5173+
Callable[
5174+
[
5175+
"MatchMapping",
5176+
AssignName,
5177+
Optional[InferenceContext],
5178+
Literal[None],
5179+
],
5180+
Generator[NodeNG, None, None],
5181+
]
51715182
]
51725183
"""Returns the assigned statement (non inferred) according to the assignment type.
51735184
See astroid/protocols.py for actual implementation.
@@ -5265,14 +5276,16 @@ def __init__(
52655276
def postinit(self, *, name: Optional[AssignName]) -> None:
52665277
self.name = name
52675278

5268-
assigned_stmts: Callable[
5269-
[
5270-
"MatchStar",
5271-
AssignName,
5272-
Optional[InferenceContext],
5273-
Literal[None],
5274-
],
5275-
Generator[NodeNG, None, None],
5279+
assigned_stmts: ClassVar[
5280+
Callable[
5281+
[
5282+
"MatchStar",
5283+
AssignName,
5284+
Optional[InferenceContext],
5285+
Literal[None],
5286+
],
5287+
Generator[NodeNG, None, None],
5288+
]
52765289
]
52775290
"""Returns the assigned statement (non inferred) according to the assignment type.
52785291
See astroid/protocols.py for actual implementation.
@@ -5334,14 +5347,16 @@ def postinit(
53345347
self.pattern = pattern
53355348
self.name = name
53365349

5337-
assigned_stmts: Callable[
5338-
[
5339-
"MatchAs",
5340-
AssignName,
5341-
Optional[InferenceContext],
5342-
Literal[None],
5343-
],
5344-
Generator[NodeNG, None, None],
5350+
assigned_stmts: ClassVar[
5351+
Callable[
5352+
[
5353+
"MatchAs",
5354+
AssignName,
5355+
Optional[InferenceContext],
5356+
Literal[None],
5357+
],
5358+
Generator[NodeNG, None, None],
5359+
]
53455360
]
53465361
"""Returns the assigned statement (non inferred) according to the assignment type.
53475362
See astroid/protocols.py for actual implementation.

0 commit comments

Comments
 (0)