@@ -321,12 +321,12 @@ class Binding(object):
321
321
the node that this binding was last used.
322
322
"""
323
323
324
- def __init__ (self , name , source , during_type_checking ):
324
+ def __init__ (self , name , source , for_annotations ):
325
325
self .name = name
326
326
self .source = source
327
327
self .used = False
328
- assert isinstance (during_type_checking , bool )
329
- self .during_type_checking = during_type_checking
328
+ assert isinstance (for_annotations , bool )
329
+ self .for_annotations = for_annotations
330
330
331
331
def __str__ (self ):
332
332
return self .name
@@ -351,7 +351,7 @@ class Builtin(Definition):
351
351
"""A definition created for all Python builtins."""
352
352
353
353
def __init__ (self , name ):
354
- super (Builtin , self ).__init__ (name , None , during_type_checking = False )
354
+ super (Builtin , self ).__init__ (name , None , for_annotations = False )
355
355
356
356
def __repr__ (self ):
357
357
return '<%s object %r at 0x%x>' % (self .__class__ .__name__ ,
@@ -393,11 +393,11 @@ class Importation(Definition):
393
393
@type fullName: C{str}
394
394
"""
395
395
396
- def __init__ (self , name , source , during_type_checking , full_name = None ):
396
+ def __init__ (self , name , source , for_annotations , full_name = None ):
397
397
self .fullName = full_name or name
398
398
self .redefined = []
399
399
super (Importation , self ).__init__ (name , source ,
400
- during_type_checking = during_type_checking )
400
+ for_annotations = for_annotations )
401
401
402
402
def redefines (self , other ):
403
403
if isinstance (other , SubmoduleImportation ):
@@ -442,12 +442,12 @@ class SubmoduleImportation(Importation):
442
442
name is also the same, to avoid false positives.
443
443
"""
444
444
445
- def __init__ (self , name , source , during_type_checking ):
445
+ def __init__ (self , name , source , for_annotations ):
446
446
# A dot should only appear in the name when it is a submodule import
447
447
assert '.' in name and (not source or isinstance (source , ast .Import ))
448
448
package_name = name .split ('.' )[0 ]
449
449
super (SubmoduleImportation , self ).__init__ (
450
- package_name , source , during_type_checking = during_type_checking )
450
+ package_name , source , for_annotations = for_annotations )
451
451
self .fullName = name
452
452
453
453
def redefines (self , other ):
@@ -465,7 +465,7 @@ def source_statement(self):
465
465
466
466
class ImportationFrom (Importation ):
467
467
468
- def __init__ (self , name , source , module , during_type_checking , real_name = None ):
468
+ def __init__ (self , name , source , module , for_annotations , real_name = None ):
469
469
self .module = module
470
470
self .real_name = real_name or name
471
471
@@ -475,7 +475,7 @@ def __init__(self, name, source, module, during_type_checking, real_name=None):
475
475
full_name = module + '.' + self .real_name
476
476
477
477
super (ImportationFrom , self ).__init__ (name , source , full_name = full_name ,
478
- during_type_checking = during_type_checking )
478
+ for_annotations = for_annotations )
479
479
480
480
def __str__ (self ):
481
481
"""Return import full name with alias."""
@@ -497,9 +497,9 @@ def source_statement(self):
497
497
class StarImportation (Importation ):
498
498
"""A binding created by a 'from x import *' statement."""
499
499
500
- def __init__ (self , name , source , during_type_checking ):
500
+ def __init__ (self , name , source , for_annotations ):
501
501
super (StarImportation , self ).__init__ ('*' , source ,
502
- during_type_checking = during_type_checking )
502
+ for_annotations = for_annotations )
503
503
# Each star importation needs a unique name, and
504
504
# may not be the module name otherwise it will be deemed imported
505
505
self .name = name + '.*'
@@ -526,7 +526,7 @@ class FutureImportation(ImportationFrom):
526
526
527
527
def __init__ (self , name , source , scope ):
528
528
super (FutureImportation , self ).__init__ (name , source , '__future__' ,
529
- during_type_checking = False )
529
+ for_annotations = False )
530
530
self .used = (scope , source )
531
531
532
532
@@ -535,7 +535,7 @@ class Argument(Binding):
535
535
Represents binding a name as an argument.
536
536
"""
537
537
def __init__ (self , name , source ):
538
- super (Argument , self ).__init__ (name , source , during_type_checking = False )
538
+ super (Argument , self ).__init__ (name , source , for_annotations = False )
539
539
540
540
541
541
class Assignment (Binding ):
@@ -585,7 +585,7 @@ class ExportBinding(Binding):
585
585
C{__all__} will not have an unused import warning reported for them.
586
586
"""
587
587
588
- def __init__ (self , name , source , scope , during_type_checking ):
588
+ def __init__ (self , name , source , scope , for_annotations ):
589
589
if '__all__' in scope and isinstance (source , ast .AugAssign ):
590
590
self .names = list (scope ['__all__' ].names )
591
591
else :
@@ -616,7 +616,7 @@ def _add_to_names(container):
616
616
# If not list concatenation
617
617
else :
618
618
break
619
- super (ExportBinding , self ).__init__ (name , source , during_type_checking )
619
+ super (ExportBinding , self ).__init__ (name , source , for_annotations )
620
620
621
621
622
622
class Scope (dict ):
@@ -1228,7 +1228,7 @@ def handleNodeLoad(self, node):
1228
1228
scope [n .fullName ].used = (self .scope , node )
1229
1229
except KeyError :
1230
1230
pass
1231
- if n .during_type_checking and not self ._in_annotation :
1231
+ if n .for_annotations and not self ._in_annotation :
1232
1232
# Only defined during type-checking; this does not count. Real code
1233
1233
# (not an annotation) using this binding will not work.
1234
1234
continue
@@ -1294,14 +1294,14 @@ def handleNodeStore(self, node):
1294
1294
elif isinstance (parent_stmt , (FOR_TYPES , ast .comprehension )) or (
1295
1295
parent_stmt != node ._pyflakes_parent and
1296
1296
not self .isLiteralTupleUnpacking (parent_stmt )):
1297
- binding = Binding (name , node , during_type_checking = self ._in_type_checking )
1297
+ binding = Binding (name , node , for_annotations = self ._in_type_checking )
1298
1298
elif name == '__all__' and isinstance (self .scope , ModuleScope ):
1299
1299
binding = ExportBinding (name , node ._pyflakes_parent , self .scope ,
1300
- during_type_checking = self ._in_type_checking )
1300
+ for_annotations = self ._in_type_checking )
1301
1301
elif PY2 and isinstance (getattr (node , 'ctx' , None ), ast .Param ):
1302
1302
binding = Argument (name , self .getScopeNode (node ))
1303
1303
else :
1304
- binding = Assignment (name , node , during_type_checking = self ._in_type_checking )
1304
+ binding = Assignment (name , node , for_annotations = self ._in_type_checking )
1305
1305
self .addBinding (node , binding )
1306
1306
1307
1307
def handleNodeDelete (self , node ):
@@ -2017,7 +2017,7 @@ def GLOBAL(self, node):
2017
2017
# One 'global' statement can bind multiple (comma-delimited) names.
2018
2018
for node_name in node .names :
2019
2019
node_value = Assignment (node_name , node ,
2020
- during_type_checking = self ._in_type_checking )
2020
+ for_annotations = self ._in_type_checking )
2021
2021
2022
2022
# Remove UndefinedName messages already reported for this name.
2023
2023
# TODO: if the global is not used in this scope, it does not
@@ -2120,7 +2120,7 @@ def FUNCTIONDEF(self, node):
2120
2120
self .handleNode (deco , node )
2121
2121
self .LAMBDA (node )
2122
2122
self .addBinding (node , FunctionDefinition (
2123
- node .name , node , during_type_checking = self ._in_type_checking ))
2123
+ node .name , node , for_annotations = self ._in_type_checking ))
2124
2124
# doctest does not process doctest within a doctest,
2125
2125
# or in nested functions.
2126
2126
if (self .withDoctest and
@@ -2246,7 +2246,7 @@ def CLASSDEF(self, node):
2246
2246
self .handleNode (stmt , node )
2247
2247
self .popScope ()
2248
2248
self .addBinding (node , ClassDefinition (
2249
- node .name , node , during_type_checking = self ._in_type_checking ))
2249
+ node .name , node , for_annotations = self ._in_type_checking ))
2250
2250
2251
2251
def AUGASSIGN (self , node ):
2252
2252
self .handleNodeLoad (node .target )
@@ -2282,11 +2282,11 @@ def IMPORT(self, node):
2282
2282
for alias in node .names :
2283
2283
if '.' in alias .name and not alias .asname :
2284
2284
importation = SubmoduleImportation (
2285
- alias .name , node , during_type_checking = self ._in_type_checking )
2285
+ alias .name , node , for_annotations = self ._in_type_checking )
2286
2286
else :
2287
2287
name = alias .asname or alias .name
2288
2288
importation = Importation (name , node , full_name = alias .name ,
2289
- during_type_checking = self ._in_type_checking )
2289
+ for_annotations = self ._in_type_checking )
2290
2290
self .addBinding (node , importation )
2291
2291
2292
2292
def IMPORTFROM (self , node ):
@@ -2317,11 +2317,11 @@ def IMPORTFROM(self, node):
2317
2317
self .scope .importStarred = True
2318
2318
self .report (messages .ImportStarUsed , node , module )
2319
2319
importation = StarImportation (
2320
- module , node , during_type_checking = self ._in_type_checking )
2320
+ module , node , for_annotations = self ._in_type_checking )
2321
2321
else :
2322
2322
importation = ImportationFrom (
2323
2323
name , node , module , real_name = alias .name ,
2324
- during_type_checking = self ._in_type_checking )
2324
+ for_annotations = self ._in_type_checking )
2325
2325
self .addBinding (node , importation )
2326
2326
2327
2327
def TRY (self , node ):
0 commit comments