@@ -6631,34 +6631,55 @@ def test_imported_module_var_inferable() -> None:
6631
6631
"""
6632
6632
Module variables can be imported and inferred successfully as part of binary operators.
6633
6633
"""
6634
- mod1 = parse ("from top1.mod import v as z\n " + "w = [1] + z" , module_name = "top1" )
6634
+ mod1 = parse (
6635
+ textwrap .dedent (
6636
+ """
6637
+ from top1.mod import v as z
6638
+ w = [1] + z
6639
+ """
6640
+ ),
6641
+ module_name = "top1" ,
6642
+ )
6635
6643
parse ("v = [2]" , module_name = "top1.mod" )
6636
6644
w_val = mod1 .body [- 1 ].value
6637
6645
i_w_val = next (w_val .infer ())
6638
- assert i_w_val != util .Uninferable
6646
+ assert i_w_val is not util .Uninferable
6639
6647
assert i_w_val .as_string () == "[1, 2]"
6640
6648
6641
6649
6642
6650
def test_imported_module_var_inferable2 () -> None :
6643
6651
"""Version list of strings."""
6644
- mod1 = parse ("from top2.mod import v as z\n " + "w = ['1'] + z" , module_name = "top2" )
6652
+ mod2 = parse (
6653
+ textwrap .dedent (
6654
+ """
6655
+ from top2.mod import v as z
6656
+ w = ['1'] + z
6657
+ """
6658
+ ),
6659
+ module_name = "top2" ,
6660
+ )
6645
6661
parse ("v = ['2']" , module_name = "top2.mod" )
6646
- w_val = mod1 .body [- 1 ].value
6662
+ w_val = mod2 .body [- 1 ].value
6647
6663
i_w_val = next (w_val .infer ())
6648
- assert i_w_val != util .Uninferable
6664
+ assert i_w_val is not util .Uninferable
6649
6665
assert i_w_val .as_string () == "['1', '2']"
6650
6666
6651
6667
6652
6668
def test_imported_module_var_inferable3 () -> None :
6653
6669
"""Version list of strings with a __dunder__ name."""
6654
- mod1 = parse (
6655
- "from top3.mod import __dunder_var__ as v\n " + "__dunder_var__ = ['w'] + v" ,
6670
+ mod3 = parse (
6671
+ textwrap .dedent (
6672
+ """
6673
+ from top3.mod import __dunder_var__ as v
6674
+ __dunder_var__ = ['w'] + v
6675
+ """
6676
+ ),
6656
6677
module_name = "top" ,
6657
6678
)
6658
6679
parse ("__dunder_var__ = ['v']" , module_name = "top3.mod" )
6659
- w_val = mod1 .body [- 1 ].value
6680
+ w_val = mod3 .body [- 1 ].value
6660
6681
i_w_val = next (w_val .infer ())
6661
- assert i_w_val != util .Uninferable
6682
+ assert i_w_val is not util .Uninferable
6662
6683
assert i_w_val .as_string () == "['w', 'v']"
6663
6684
6664
6685
0 commit comments