From 20890b81cebd40fc928834de64e48ff80100cec5 Mon Sep 17 00:00:00 2001 From: Artem Yurchenko Date: Mon, 9 Sep 2024 11:12:33 -0700 Subject: [PATCH] set namespace's parent to adhoc module instead of Unknown it's a part of the campaign to get rid of non-module roots --- astroid/brain/brain_argparse.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/astroid/brain/brain_argparse.py b/astroid/brain/brain_argparse.py index 500b8d74cd..2e6b742c38 100644 --- a/astroid/brain/brain_argparse.py +++ b/astroid/brain/brain_argparse.py @@ -21,13 +21,10 @@ def infer_namespace(node, context: InferenceContext | None = None): "Namespace", lineno=node.lineno, col_offset=node.col_offset, - parent=nodes.Unknown(), + parent=AstroidManager().adhoc_module, # this class is not real end_lineno=node.end_lineno, end_col_offset=node.end_col_offset, ) - # Set parent manually until ClassDef constructor fixed: - # https://github.com/pylint-dev/astroid/issues/1490 - class_node.parent = node.parent for attr in set(callsite.keyword_arguments): fake_node = nodes.EmptyNode() fake_node.parent = class_node