diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index 59f359f783..2676c127c8 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -1616,13 +1616,7 @@ def is_node_in_type_annotation_context(node: nodes.NodeNG) -> bool: match parent_node: case nodes.AnnAssign(annotation=ann) if ann == current_node: return True - case nodes.Arguments() if current_node in ( - *parent_node.annotations, - *parent_node.posonlyargs_annotations, - *parent_node.kwonlyargs_annotations, - parent_node.varargannotation, - parent_node.kwargannotation, - ): + case nodes.Arguments() if current_node in parent_node.get_annotations(): return True case nodes.FunctionDef(returns=ret) if ret == current_node: return True diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index 9d0c6ba6a6..c422b67463 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -2211,13 +2211,7 @@ def _defined_in_function_definition( in_annotation_or_default_or_decorator = False if isinstance(frame, nodes.FunctionDef) and node.statement() is frame: in_annotation_or_default_or_decorator = ( - ( - node in frame.args.annotations - or node in frame.args.posonlyargs_annotations - or node in frame.args.kwonlyargs_annotations - or node is frame.args.varargannotation - or node is frame.args.kwargannotation - ) + node in frame.args.get_annotations() or frame.args.parent_of(node) or (frame.decorators and frame.decorators.parent_of(node)) or (