-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
argparse
brain: avoid spurious addition of "namespace" to function …
…locals
- Loading branch information
1 parent
b30977e
commit 824abdb
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html | ||
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE | ||
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt | ||
|
||
from astroid import bases, extract_node, nodes | ||
|
||
|
||
class TestBrainArgparse: | ||
@staticmethod | ||
def test_infer_namespace() -> None: | ||
func = extract_node( | ||
""" | ||
import argparse | ||
def make_namespace(): #@ | ||
return argparse.Namespace(debug=True) | ||
""" | ||
) | ||
assert isinstance(func, nodes.FunctionDef) | ||
inferred = next(func.infer_call_result(func)) | ||
assert isinstance(inferred, bases.Instance) | ||
assert not func.locals |