@@ -310,12 +310,12 @@ class Binding(object):
310
310
the node that this binding was last used.
311
311
"""
312
312
313
- def __init__ (self , name , source , during_type_checking ):
313
+ def __init__ (self , name , source , for_annotations ):
314
314
self .name = name
315
315
self .source = source
316
316
self .used = False
317
- assert isinstance (during_type_checking , bool )
318
- self .during_type_checking = during_type_checking
317
+ assert isinstance (for_annotations , bool )
318
+ self .for_annotations = for_annotations
319
319
320
320
def __str__ (self ):
321
321
return self .name
@@ -340,7 +340,7 @@ class Builtin(Definition):
340
340
"""A definition created for all Python builtins."""
341
341
342
342
def __init__ (self , name ):
343
- super (Builtin , self ).__init__ (name , None , during_type_checking = False )
343
+ super (Builtin , self ).__init__ (name , None , for_annotations = False )
344
344
345
345
def __repr__ (self ):
346
346
return '<%s object %r at 0x%x>' % (self .__class__ .__name__ ,
@@ -382,11 +382,11 @@ class Importation(Definition):
382
382
@type fullName: C{str}
383
383
"""
384
384
385
- def __init__ (self , name , source , during_type_checking , full_name = None ):
385
+ def __init__ (self , name , source , for_annotations , full_name = None ):
386
386
self .fullName = full_name or name
387
387
self .redefined = []
388
388
super (Importation , self ).__init__ (name , source ,
389
- during_type_checking = during_type_checking )
389
+ for_annotations = for_annotations )
390
390
391
391
def redefines (self , other ):
392
392
if isinstance (other , SubmoduleImportation ):
@@ -431,12 +431,12 @@ class SubmoduleImportation(Importation):
431
431
name is also the same, to avoid false positives.
432
432
"""
433
433
434
- def __init__ (self , name , source , during_type_checking ):
434
+ def __init__ (self , name , source , for_annotations ):
435
435
# A dot should only appear in the name when it is a submodule import
436
436
assert '.' in name and (not source or isinstance (source , ast .Import ))
437
437
package_name = name .split ('.' )[0 ]
438
438
super (SubmoduleImportation , self ).__init__ (
439
- package_name , source , during_type_checking = during_type_checking )
439
+ package_name , source , for_annotations = for_annotations )
440
440
self .fullName = name
441
441
442
442
def redefines (self , other ):
@@ -454,7 +454,7 @@ def source_statement(self):
454
454
455
455
class ImportationFrom (Importation ):
456
456
457
- def __init__ (self , name , source , module , during_type_checking , real_name = None ):
457
+ def __init__ (self , name , source , module , for_annotations , real_name = None ):
458
458
self .module = module
459
459
self .real_name = real_name or name
460
460
@@ -464,7 +464,7 @@ def __init__(self, name, source, module, during_type_checking, real_name=None):
464
464
full_name = module + '.' + self .real_name
465
465
466
466
super (ImportationFrom , self ).__init__ (name , source , full_name = full_name ,
467
- during_type_checking = during_type_checking )
467
+ for_annotations = for_annotations )
468
468
469
469
def __str__ (self ):
470
470
"""Return import full name with alias."""
@@ -486,9 +486,9 @@ def source_statement(self):
486
486
class StarImportation (Importation ):
487
487
"""A binding created by a 'from x import *' statement."""
488
488
489
- def __init__ (self , name , source , during_type_checking ):
489
+ def __init__ (self , name , source , for_annotations ):
490
490
super (StarImportation , self ).__init__ ('*' , source ,
491
- during_type_checking = during_type_checking )
491
+ for_annotations = for_annotations )
492
492
# Each star importation needs a unique name, and
493
493
# may not be the module name otherwise it will be deemed imported
494
494
self .name = name + '.*'
@@ -515,7 +515,7 @@ class FutureImportation(ImportationFrom):
515
515
516
516
def __init__ (self , name , source , scope ):
517
517
super (FutureImportation , self ).__init__ (name , source , '__future__' ,
518
- during_type_checking = False )
518
+ for_annotations = False )
519
519
self .used = (scope , source )
520
520
521
521
@@ -524,7 +524,7 @@ class Argument(Binding):
524
524
Represents binding a name as an argument.
525
525
"""
526
526
def __init__ (self , name , source ):
527
- super (Argument , self ).__init__ (name , source , during_type_checking = False )
527
+ super (Argument , self ).__init__ (name , source , for_annotations = False )
528
528
529
529
530
530
class Assignment (Binding ):
@@ -560,7 +560,7 @@ class ExportBinding(Binding):
560
560
C{__all__} will not have an unused import warning reported for them.
561
561
"""
562
562
563
- def __init__ (self , name , source , scope , during_type_checking ):
563
+ def __init__ (self , name , source , scope , for_annotations ):
564
564
if '__all__' in scope and isinstance (source , ast .AugAssign ):
565
565
self .names = list (scope ['__all__' ].names )
566
566
else :
@@ -591,7 +591,7 @@ def _add_to_names(container):
591
591
# If not list concatenation
592
592
else :
593
593
break
594
- super (ExportBinding , self ).__init__ (name , source , during_type_checking )
594
+ super (ExportBinding , self ).__init__ (name , source , for_annotations )
595
595
596
596
597
597
class Scope (dict ):
@@ -1175,7 +1175,7 @@ def handleNodeLoad(self, node):
1175
1175
scope [n .fullName ].used = (self .scope , node )
1176
1176
except KeyError :
1177
1177
pass
1178
- if n .during_type_checking and not self ._in_annotation :
1178
+ if n .for_annotations and not self ._in_annotation :
1179
1179
# Only defined during type-checking; this does not count. Real code
1180
1180
# (not an annotation) using this binding will not work.
1181
1181
continue
@@ -1239,14 +1239,14 @@ def handleNodeStore(self, node):
1239
1239
if isinstance (parent_stmt , (FOR_TYPES , ast .comprehension )) or (
1240
1240
parent_stmt != node ._pyflakes_parent and
1241
1241
not self .isLiteralTupleUnpacking (parent_stmt )):
1242
- binding = Binding (name , node , during_type_checking = self ._in_type_checking )
1242
+ binding = Binding (name , node , for_annotations = self ._in_type_checking )
1243
1243
elif name == '__all__' and isinstance (self .scope , ModuleScope ):
1244
1244
binding = ExportBinding (name , node ._pyflakes_parent , self .scope ,
1245
- during_type_checking = self ._in_type_checking )
1245
+ for_annotations = self ._in_type_checking )
1246
1246
elif PY2 and isinstance (getattr (node , 'ctx' , None ), ast .Param ):
1247
1247
binding = Argument (name , self .getScopeNode (node ))
1248
1248
else :
1249
- binding = Assignment (name , node , during_type_checking = self ._in_type_checking )
1249
+ binding = Assignment (name , node , for_annotations = self ._in_type_checking )
1250
1250
self .addBinding (node , binding )
1251
1251
1252
1252
def handleNodeDelete (self , node ):
@@ -1875,7 +1875,7 @@ def GLOBAL(self, node):
1875
1875
# One 'global' statement can bind multiple (comma-delimited) names.
1876
1876
for node_name in node .names :
1877
1877
node_value = Assignment (node_name , node ,
1878
- during_type_checking = self ._in_type_checking )
1878
+ for_annotations = self ._in_type_checking )
1879
1879
1880
1880
# Remove UndefinedName messages already reported for this name.
1881
1881
# TODO: if the global is not used in this scope, it does not
@@ -1978,7 +1978,7 @@ def FUNCTIONDEF(self, node):
1978
1978
self .handleNode (deco , node )
1979
1979
self .LAMBDA (node )
1980
1980
self .addBinding (node , FunctionDefinition (
1981
- node .name , node , during_type_checking = self ._in_type_checking ))
1981
+ node .name , node , for_annotations = self ._in_type_checking ))
1982
1982
# doctest does not process doctest within a doctest,
1983
1983
# or in nested functions.
1984
1984
if (self .withDoctest and
@@ -2104,7 +2104,7 @@ def CLASSDEF(self, node):
2104
2104
self .handleNode (stmt , node )
2105
2105
self .popScope ()
2106
2106
self .addBinding (node , ClassDefinition (
2107
- node .name , node , during_type_checking = self ._in_type_checking ))
2107
+ node .name , node , for_annotations = self ._in_type_checking ))
2108
2108
2109
2109
def AUGASSIGN (self , node ):
2110
2110
self .handleNodeLoad (node .target )
@@ -2140,11 +2140,11 @@ def IMPORT(self, node):
2140
2140
for alias in node .names :
2141
2141
if '.' in alias .name and not alias .asname :
2142
2142
importation = SubmoduleImportation (
2143
- alias .name , node , during_type_checking = self ._in_type_checking )
2143
+ alias .name , node , for_annotations = self ._in_type_checking )
2144
2144
else :
2145
2145
name = alias .asname or alias .name
2146
2146
importation = Importation (name , node , full_name = alias .name ,
2147
- during_type_checking = self ._in_type_checking )
2147
+ for_annotations = self ._in_type_checking )
2148
2148
self .addBinding (node , importation )
2149
2149
2150
2150
def IMPORTFROM (self , node ):
@@ -2175,11 +2175,11 @@ def IMPORTFROM(self, node):
2175
2175
self .scope .importStarred = True
2176
2176
self .report (messages .ImportStarUsed , node , module )
2177
2177
importation = StarImportation (
2178
- module , node , during_type_checking = self ._in_type_checking )
2178
+ module , node , for_annotations = self ._in_type_checking )
2179
2179
else :
2180
2180
importation = ImportationFrom (
2181
2181
name , node , module , real_name = alias .name ,
2182
- during_type_checking = self ._in_type_checking )
2182
+ for_annotations = self ._in_type_checking )
2183
2183
self .addBinding (node , importation )
2184
2184
2185
2185
def TRY (self , node ):
0 commit comments