Skip to content

Commit 5405b6c

Browse files
authored
Add typing to FunctionDef decorators attributes (#1345)
1 parent e99fae1 commit 5405b6c

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

astroid/nodes/scoped_nodes/scoped_nodes.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,11 +1503,8 @@ class FunctionDef(mixins.MultiLineBlockMixin, node_classes.Statement, Lambda):
15031503
_astroid_fields = ("decorators", "args", "returns", "body")
15041504
_multi_line_block_fields = ("body",)
15051505
returns = None
1506-
decorators = None
1507-
"""The decorators that are applied to this method or function.
1508-
1509-
:type: Decorators or None
1510-
"""
1506+
decorators: Optional[node_classes.Decorators] = None
1507+
"""The decorators that are applied to this method or function."""
15111508
special_attributes = FunctionModel()
15121509
"""The names of special attributes that this function has.
15131510
@@ -1606,7 +1603,7 @@ def postinit(
16061603
self,
16071604
args: Arguments,
16081605
body,
1609-
decorators=None,
1606+
decorators: Optional[node_classes.Decorators] = None,
16101607
returns=None,
16111608
type_comment_returns=None,
16121609
type_comment_args=None,
@@ -1634,21 +1631,19 @@ def postinit(
16341631
self.type_comment_args = type_comment_args
16351632

16361633
@decorators_mod.cachedproperty
1637-
def extra_decorators(self):
1634+
def extra_decorators(self) -> List[node_classes.Call]:
16381635
"""The extra decorators that this function can have.
16391636
16401637
Additional decorators are considered when they are used as
16411638
assignments, as in ``method = staticmethod(method)``.
16421639
The property will return all the callables that are used for
16431640
decoration.
1644-
1645-
:type: list(NodeNG)
16461641
"""
16471642
frame = self.parent.frame(future=True)
16481643
if not isinstance(frame, ClassDef):
16491644
return []
16501645

1651-
decorators = []
1646+
decorators: List[node_classes.Call] = []
16521647
for assign in frame._get_assign_nodes():
16531648
if isinstance(assign.value, node_classes.Call) and isinstance(
16541649
assign.value.func, node_classes.Name

0 commit comments

Comments
 (0)