summaryrefslogtreecommitdiff
path: root/astroid/nodes/node_classes.py
diff options
context:
space:
mode:
authorDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2023-04-03 22:39:38 +0200
committerDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2023-04-03 22:53:40 +0200
commit81c6c8fb32d89c9db35c541a06b5d2e43180a5c1 (patch)
tree95f2242f6d715f64ba8b6c37f0d339c7f3de9044 /astroid/nodes/node_classes.py
parente13e1770e3cb915da270261d185ec235928e2124 (diff)
downloadastroid-git-81c6c8fb32d89c9db35c541a06b5d2e43180a5c1.tar.gz
Formalize the ``block_range`` methods on nodes
Diffstat (limited to 'astroid/nodes/node_classes.py')
-rw-r--r--astroid/nodes/node_classes.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py
index 81d7658a..46928f2b 100644
--- a/astroid/nodes/node_classes.py
+++ b/astroid/nodes/node_classes.py
@@ -2797,15 +2797,13 @@ class If(_base_nodes.MultiLineWithElseBlockNode, _base_nodes.Statement):
"""
return self.test.tolineno
- def block_range(self, lineno):
+ def block_range(self, lineno: int) -> tuple[int, int]:
"""Get a range from the given line number to where this node ends.
:param lineno: The line number to start the range at.
- :type lineno: int
:returns: The range of line numbers that this node belongs to,
starting at the given line number.
- :rtype: tuple(int, int)
"""
if lineno == self.body[0].fromlineno:
return lineno, lineno
@@ -3622,15 +3620,13 @@ class TryExcept(_base_nodes.MultiLineWithElseBlockNode, _base_nodes.Statement):
def _infer_name(self, frame, name):
return name
- def block_range(self, lineno):
+ def block_range(self, lineno: int) -> tuple[int, int]:
"""Get a range from the given line number to where this node ends.
:param lineno: The line number to start the range at.
- :type lineno: int
:returns: The range of line numbers that this node belongs to,
starting at the given line number.
- :rtype: tuple(int, int)
"""
last = None
for exhandler in self.handlers:
@@ -3720,15 +3716,13 @@ class TryFinally(_base_nodes.MultiLineWithElseBlockNode, _base_nodes.Statement):
if finalbody is not None:
self.finalbody = finalbody
- def block_range(self, lineno):
+ def block_range(self, lineno: int) -> tuple[int, int]:
"""Get a range from the given line number to where this node ends.
:param lineno: The line number to start the range at.
- :type lineno: int
:returns: The range of line numbers that this node belongs to,
starting at the given line number.
- :rtype: tuple(int, int)
"""
child = self.body[0]
# py2.5 try: except: finally:
@@ -4072,15 +4066,13 @@ class While(_base_nodes.MultiLineWithElseBlockNode, _base_nodes.Statement):
"""
return self.test.tolineno
- def block_range(self, lineno):
+ def block_range(self, lineno: int) -> tuple[int, int]:
"""Get a range from the given line number to where this node ends.
:param lineno: The line number to start the range at.
- :type lineno: int
:returns: The range of line numbers that this node belongs to,
starting at the given line number.
- :rtype: tuple(int, int)
"""
return self._elsed_block_range(lineno, self.orelse)