Skip to content

Commit

Permalink
[unbalanced-tuple-unpacking] Add a regression tests for #7710
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Sep 24, 2023
1 parent 24786fa commit aea47d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/7710.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``sys.argv`` is now always correctly considered as impossible to infer (instead of
using the actual values given to pylint).

Closes #7710
7 changes: 7 additions & 0 deletions tests/functional/u/unbalanced_tuple_unpacking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Check possible unbalanced tuple unpacking """
from __future__ import absolute_import

import sys
from typing import NamedTuple
from functional.u.unpacking.unpacking import unpack

Expand Down Expand Up @@ -160,3 +162,8 @@ def my_function(mystring):

# https://github.com/pylint-dev/pylint/issues/5998
x, y, z = (1, 2) # [unbalanced-tuple-unpacking]

# https://github.com/pylint-dev/pylint/issues/7710
# Using a lot of args, so we have a high probability to still trigger the problem if
# we add arguments to our unittest command later
(p, q, r, s, t, u, v, w, x, y, z) = sys.argv
18 changes: 9 additions & 9 deletions tests/functional/u/unbalanced_tuple_unpacking.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
unbalanced-tuple-unpacking:11:4:11:27:do_stuff:"Possible unbalanced tuple unpacking with sequence '(1, 2, 3)': left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:17:4:17:29:do_stuff1:"Possible unbalanced tuple unpacking with sequence '[1, 2, 3]': left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:23:4:23:29:do_stuff2:"Possible unbalanced tuple unpacking with sequence '(1, 2, 3)': left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:82:4:82:28:do_stuff9:"Possible unbalanced tuple unpacking with sequence defined at line 7 of functional.u.unpacking.unpacking: left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:96:8:96:33:UnbalancedUnpacking.test:"Possible unbalanced tuple unpacking with sequence defined at line 7 of functional.u.unpacking.unpacking: left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:140:8:140:43:MyClass.sum_unpack_3_into_4:"Possible unbalanced tuple unpacking with sequence defined at line 128: left side has 4 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:145:8:145:28:MyClass.sum_unpack_3_into_2:"Possible unbalanced tuple unpacking with sequence defined at line 128: left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:157:0:157:24::"Possible unbalanced tuple unpacking with sequence defined at line 151: left side has 2 labels, right side has 0 values":INFERENCE
unbalanced-tuple-unpacking:162:0:162:16::"Possible unbalanced tuple unpacking with sequence '(1, 2)': left side has 3 labels, right side has 2 values":INFERENCE
unbalanced-tuple-unpacking:13:4:13:27:do_stuff:"Possible unbalanced tuple unpacking with sequence '(1, 2, 3)': left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:19:4:19:29:do_stuff1:"Possible unbalanced tuple unpacking with sequence '[1, 2, 3]': left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:25:4:25:29:do_stuff2:"Possible unbalanced tuple unpacking with sequence '(1, 2, 3)': left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:84:4:84:28:do_stuff9:"Possible unbalanced tuple unpacking with sequence defined at line 7 of functional.u.unpacking.unpacking: left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:98:8:98:33:UnbalancedUnpacking.test:"Possible unbalanced tuple unpacking with sequence defined at line 7 of functional.u.unpacking.unpacking: left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:142:8:142:43:MyClass.sum_unpack_3_into_4:"Possible unbalanced tuple unpacking with sequence defined at line 130: left side has 4 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:147:8:147:28:MyClass.sum_unpack_3_into_2:"Possible unbalanced tuple unpacking with sequence defined at line 130: left side has 2 labels, right side has 3 values":INFERENCE
unbalanced-tuple-unpacking:159:0:159:24::"Possible unbalanced tuple unpacking with sequence defined at line 153: left side has 2 labels, right side has 0 values":INFERENCE
unbalanced-tuple-unpacking:164:0:164:16::"Possible unbalanced tuple unpacking with sequence '(1, 2)': left side has 3 labels, right side has 2 values":INFERENCE

0 comments on commit aea47d1

Please sign in to comment.