File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1099,7 +1099,12 @@ def _infer_attribute(
1099
1099
if isinstance (owner , (ClassDef , Instance )):
1100
1100
frame = owner if isinstance (owner , ClassDef ) else owner ._proxied
1101
1101
context .constraints [node .attrname ] = get_constraints (node , frame = frame )
1102
- yield from owner .igetattr (node .attrname , context )
1102
+ if node .attrname == "argv" and owner .name == "sys" :
1103
+ # sys.argv will never be inferable during static analysis
1104
+ # It's value would be the args passed to the linter itself
1105
+ yield util .Uninferable
1106
+ else :
1107
+ yield from owner .igetattr (node .attrname , context )
1103
1108
except (
1104
1109
AttributeInferenceError ,
1105
1110
InferenceError ,
Original file line number Diff line number Diff line change @@ -7238,3 +7238,18 @@ def test_old_style_string_formatting_with_specs(self) -> None:
7238
7238
inferred = next (node .infer ())
7239
7239
assert isinstance (inferred , nodes .Const )
7240
7240
assert inferred .value == "My name is Daniel, I'm 12.00"
7241
+
7242
+
7243
+ def test_sys_argv_uninferable () -> None :
7244
+ """Regression test for https://github.com/pylint-dev/pylint/issues/7710."""
7245
+ a : nodes .List = extract_node (
7246
+ textwrap .dedent (
7247
+ """
7248
+ import sys
7249
+
7250
+ sys.argv"""
7251
+ )
7252
+ )
7253
+ sys_argv_value = list (a ._infer ())
7254
+ assert len (sys_argv_value ) == 1
7255
+ assert sys_argv_value [0 ] is Uninferable
You can’t perform that action at this time.
0 commit comments