@@ -3882,6 +3882,27 @@ class CaseChangeOverSubstitution:
3882
3882
actual = self .get_suggestion (cls (), 'bluch' )
3883
3883
self .assertIn (suggestion , actual )
3884
3884
3885
+ def test_getattr_suggestions_underscored (self ):
3886
+ class A :
3887
+ bluch = None
3888
+
3889
+ self .assertIn ("'bluch'" , self .get_suggestion (A (), 'blach' ))
3890
+ self .assertIn ("'bluch'" , self .get_suggestion (A (), '_luch' ))
3891
+ self .assertIn ("'bluch'" , self .get_suggestion (A (), '_bluch' ))
3892
+
3893
+ class B :
3894
+ _bluch = None
3895
+ def method (self , name ):
3896
+ getattr (self , name )
3897
+
3898
+ self .assertIn ("'_bluch'" , self .get_suggestion (B (), '_blach' ))
3899
+ self .assertIn ("'_bluch'" , self .get_suggestion (B (), '_luch' ))
3900
+ self .assertNotIn ("'_bluch'" , self .get_suggestion (B (), 'bluch' ))
3901
+
3902
+ self .assertIn ("'_bluch'" , self .get_suggestion (partial (B ().method , '_blach' )))
3903
+ self .assertIn ("'_bluch'" , self .get_suggestion (partial (B ().method , '_luch' )))
3904
+ self .assertIn ("'_bluch'" , self .get_suggestion (partial (B ().method , 'bluch' )))
3905
+
3885
3906
def test_getattr_suggestions_do_not_trigger_for_long_attributes (self ):
3886
3907
class A :
3887
3908
blech = None
@@ -4074,6 +4095,17 @@ def test_import_from_suggestions(self):
4074
4095
actual = self .get_import_from_suggestion (code , 'bluch' )
4075
4096
self .assertIn (suggestion , actual )
4076
4097
4098
+ def test_import_from_suggestions_underscored (self ):
4099
+ code = "bluch = None"
4100
+ self .assertIn ("'bluch'" , self .get_import_from_suggestion (code , 'blach' ))
4101
+ self .assertIn ("'bluch'" , self .get_import_from_suggestion (code , '_luch' ))
4102
+ self .assertIn ("'bluch'" , self .get_import_from_suggestion (code , '_bluch' ))
4103
+
4104
+ code = "_bluch = None"
4105
+ self .assertIn ("'_bluch'" , self .get_import_from_suggestion (code , '_blach' ))
4106
+ self .assertIn ("'_bluch'" , self .get_import_from_suggestion (code , '_luch' ))
4107
+ self .assertNotIn ("'_bluch'" , self .get_import_from_suggestion (code , 'bluch' ))
4108
+
4077
4109
def test_import_from_suggestions_do_not_trigger_for_long_attributes (self ):
4078
4110
code = "blech = None"
4079
4111
0 commit comments