##// END OF EJS Templates
import-checker: report local with stdlib late warning...
timeless -
r28330:f3fb24e3 default
parent child Browse files
Show More
@@ -366,7 +366,7 b' def verify_modern_convention(module, roo'
366 fromlocal = fromlocalfunc(module, localmods)
366 fromlocal = fromlocalfunc(module, localmods)
367
367
368 # Whether a local/non-stdlib import has been performed.
368 # Whether a local/non-stdlib import has been performed.
369 seenlocal = False
369 seenlocal = None
370 # Whether a relative, non-symbol import has been seen.
370 # Whether a relative, non-symbol import has been seen.
371 seennonsymbolrelative = False
371 seennonsymbolrelative = False
372 # The last name to be imported (for sorting).
372 # The last name to be imported (for sorting).
@@ -403,10 +403,11 b' def verify_modern_convention(module, roo'
403 # stdlib imports should be before local imports.
403 # stdlib imports should be before local imports.
404 stdlib = name in stdlib_modules
404 stdlib = name in stdlib_modules
405 if stdlib and seenlocal and node.col_offset == root_col_offset:
405 if stdlib and seenlocal and node.col_offset == root_col_offset:
406 yield msg('stdlib import follows local import: %s', name)
406 yield msg('stdlib import "%s" follows local import: %s',
407 name, seenlocal)
407
408
408 if not stdlib:
409 if not stdlib:
409 seenlocal = True
410 seenlocal = name
410
411
411 # Import of sibling modules should use relative imports.
412 # Import of sibling modules should use relative imports.
412 topname = name.split('.')[0]
413 topname = name.split('.')[0]
@@ -437,7 +438,7 b' def verify_modern_convention(module, roo'
437 if not fullname or fullname in stdlib_modules:
438 if not fullname or fullname in stdlib_modules:
438 yield msg('relative import of stdlib module')
439 yield msg('relative import of stdlib module')
439 else:
440 else:
440 seenlocal = True
441 seenlocal = fullname
441
442
442 # Direct symbol import is only allowed from certain modules and
443 # Direct symbol import is only allowed from certain modules and
443 # must occur before non-symbol imports.
444 # must occur before non-symbol imports.
@@ -125,7 +125,7 b' Run additional tests for the import chec'
125 testpackage/relativestdlib.py:2: relative import of stdlib module
125 testpackage/relativestdlib.py:2: relative import of stdlib module
126 testpackage/requirerelative.py:2: import should be relative: testpackage.unsorted
126 testpackage/requirerelative.py:2: import should be relative: testpackage.unsorted
127 testpackage/sortedentries.py:2: imports from testpackage not lexically sorted: bar < foo
127 testpackage/sortedentries.py:2: imports from testpackage not lexically sorted: bar < foo
128 testpackage/stdafterlocal.py:3: stdlib import follows local import: os
128 testpackage/stdafterlocal.py:3: stdlib import "os" follows local import: testpackage
129 testpackage/subpackage/levelpriority.py:3: higher-level import should come first: testpackage
129 testpackage/subpackage/levelpriority.py:3: higher-level import should come first: testpackage
130 testpackage/subpackage/localimport.py:7: multiple "from .. import" statements
130 testpackage/subpackage/localimport.py:7: multiple "from .. import" statements
131 testpackage/subpackage/localimport.py:8: import should be relative: testpackage.subpackage.levelpriority
131 testpackage/subpackage/localimport.py:8: import should be relative: testpackage.subpackage.levelpriority
General Comments 0
You need to be logged in to leave comments. Login now