sapling/eden/scm/.flake8

74 lines
3.0 KiB
Plaintext
Raw Normal View History

[flake8]
select =
flake8: resolve some F checks Summary: Solves issues below: ``` hgext/backups.py:18:1: F811 redefinition of unused 'registrar' from line 17 hgext/catnotate.py:1:1: F811 redefinition of unused 'util' from line 1 hgext/remotenames.py:57:5: F811 redefinition of unused 'registrar' from line 34 hgsubversion/setup.py:103:5: F401 'mercurial' imported but unused hgsubversion/setup.py:109:5: F401 'hgsubversion.svnwrap.svn_swig_wrapper' imported but unused i18n/polib.py:1281:29: F841 local variable 'exc' is assigned to but never used (Python 2) i18n/polib.py:1427:13: F841 local variable 'typ' is assigned to but never used i18n/polib.py:28:1: F401 'sys' imported but unused mercurial/manifest.py:411:5: F811 redefinition of unused '_lazymanifest' from line 168 mercurial/posix.py:419:5: F811 redefinition of unused 'normcasefallback' from line 362 mercurial/posix.py:425:5: F811 redefinition of unused 'checkexec' from line 167 mercurial/posix.py:431:5: F811 redefinition of unused 'checklink' from line 234 mercurial/pycompat.py:29:5: F401 'http.cookiejar as cookielib' imported but unused mercurial/pycompat.py:30:5: F401 'http.client as httplib' imported but unused mercurial/pycompat.py:31:5: F401 'pickle' imported but unused mercurial/pycompat.py:33:5: F401 'socketserver' imported but unused mercurial/pycompat.py:34:5: F401 'xmlrpc.client as xmlrpclib' imported but unused mercurial/statprof.py:573:36: F812 list comprehension redefines 'parent' from line 562 (Python 2) mercurial/util.py:1076:5: F811 redefinition of unused 'nogc' from line 1051 mercurial/util.py:3221:5: F811 redefinition of unused 'dirs' from line 3184 tests/silenttestrunner.py:24:5: F811 redefinition of unused 'main' from line 6 tests/test-context.py:90:1: F811 redefinition of unused 'scmutil' from line 4 tests/test-fb-hgext-cstore-treemanifest.py:146:5: F811 redefinition of unused 'testDeeplyNested' from line 134 tests/test-fb-hgext-extutil.py:46:5: F811 redefinition of unused 'testbgcommandfailure' from line 37 tests/test_hgsubversion_util.py:47:1: F811 redefinition of unused 'svnwrap' from line 31 (Python 2) tests/test_hgsubversion_util.py:49:1: F811 redefinition of unused 'svnwrap' from line 47 (Python 2) ``` Reviewed By: ryanmce Differential Revision: D6934533 fbshipit-source-id: 8b51851a76fec88bb59107ed05a901d42c7326f8
2018-02-10 04:31:41 +03:00
F401, # module imported but unused
F402, # import module from line N shadowed by loop variable
F403, # from module import * used; unable to detect undefined names
F404, # future import(s) name after other statements
F405, # name may be undefined, or defined from star imports: module
F406, # from module import * only allowed at module level
F407, # an undefined __future__ feature name was imported
F601, # dictionary key name repeated with different values
F602, # dictionary key variable name repeated with different values
F621, # too many expressions in an assignment with star-unpacking
F622, # two or more starred expressions in an assignment (a, *b, *c = d)
F631, # assertion test is a tuple, which are always True
F701, # a break statement outside of a while or for loop
F702, # a continue statement outside of a while or for loop
F703, # a continue statement in a finally block in a loop
F704, # a yield or yield from statement outside of a function
F705, # a return statement with arguments inside a generator
F706, # a return statement outside of a function/method
F707, # an except: block as not the last exception handler
flake8: resolve some F checks Summary: Solves issues below: ``` hgext/backups.py:18:1: F811 redefinition of unused 'registrar' from line 17 hgext/catnotate.py:1:1: F811 redefinition of unused 'util' from line 1 hgext/remotenames.py:57:5: F811 redefinition of unused 'registrar' from line 34 hgsubversion/setup.py:103:5: F401 'mercurial' imported but unused hgsubversion/setup.py:109:5: F401 'hgsubversion.svnwrap.svn_swig_wrapper' imported but unused i18n/polib.py:1281:29: F841 local variable 'exc' is assigned to but never used (Python 2) i18n/polib.py:1427:13: F841 local variable 'typ' is assigned to but never used i18n/polib.py:28:1: F401 'sys' imported but unused mercurial/manifest.py:411:5: F811 redefinition of unused '_lazymanifest' from line 168 mercurial/posix.py:419:5: F811 redefinition of unused 'normcasefallback' from line 362 mercurial/posix.py:425:5: F811 redefinition of unused 'checkexec' from line 167 mercurial/posix.py:431:5: F811 redefinition of unused 'checklink' from line 234 mercurial/pycompat.py:29:5: F401 'http.cookiejar as cookielib' imported but unused mercurial/pycompat.py:30:5: F401 'http.client as httplib' imported but unused mercurial/pycompat.py:31:5: F401 'pickle' imported but unused mercurial/pycompat.py:33:5: F401 'socketserver' imported but unused mercurial/pycompat.py:34:5: F401 'xmlrpc.client as xmlrpclib' imported but unused mercurial/statprof.py:573:36: F812 list comprehension redefines 'parent' from line 562 (Python 2) mercurial/util.py:1076:5: F811 redefinition of unused 'nogc' from line 1051 mercurial/util.py:3221:5: F811 redefinition of unused 'dirs' from line 3184 tests/silenttestrunner.py:24:5: F811 redefinition of unused 'main' from line 6 tests/test-context.py:90:1: F811 redefinition of unused 'scmutil' from line 4 tests/test-fb-hgext-cstore-treemanifest.py:146:5: F811 redefinition of unused 'testDeeplyNested' from line 134 tests/test-fb-hgext-extutil.py:46:5: F811 redefinition of unused 'testbgcommandfailure' from line 37 tests/test_hgsubversion_util.py:47:1: F811 redefinition of unused 'svnwrap' from line 31 (Python 2) tests/test_hgsubversion_util.py:49:1: F811 redefinition of unused 'svnwrap' from line 47 (Python 2) ``` Reviewed By: ryanmce Differential Revision: D6934533 fbshipit-source-id: 8b51851a76fec88bb59107ed05a901d42c7326f8
2018-02-10 04:31:41 +03:00
F811, # redefinition of unused name from line N
F812, # list comprehension redefines name from line N
flake8: enable F821 check Summary: This check is useful and detects real errors (ex. fbconduit). Unfortunately `arc lint` will run it with both py2 and py3 so a lot of py2 builtins will still be warned. I didn't find a clean way to disable py3 check. So this diff tries to fix them. For `xrange`, the change was done by a script: ``` import sys import redbaron headertypes = {'comment', 'endl', 'from_import', 'import', 'string', 'assignment', 'atomtrailers'} xrangefix = '''try: xrange(0) except NameError: xrange = range ''' def isxrange(x): try: return x[0].value == 'xrange' except Exception: return False def main(argv): for i, path in enumerate(argv): print('(%d/%d) scanning %s' % (i + 1, len(argv), path)) content = open(path).read() try: red = redbaron.RedBaron(content) except Exception: print(' warning: failed to parse') continue hasxrange = red.find('atomtrailersnode', value=isxrange) hasxrangefix = 'xrange = range' in content if hasxrangefix or not hasxrange: print(' no need to change') continue # find a place to insert the compatibility statement changed = False for node in red: if node.type in headertypes: continue # node.insert_before is an easier API, but it has bugs changing # other "finally" and "except" positions. So do the insert # manually. # # node.insert_before(xrangefix) line = node.absolute_bounding_box.top_left.line - 1 lines = content.splitlines(1) content = ''.join(lines[:line]) + xrangefix + ''.join(lines[line:]) changed = True break if changed: # "content" is faster than "red.dumps()" open(path, 'w').write(content) print(' updated') if __name__ == "__main__": sys.exit(main(sys.argv[1:])) ``` For other py2 builtins that do not have a py3 equivalent, some `# noqa` were added as a workaround for now. Reviewed By: DurhamG Differential Revision: D6934535 fbshipit-source-id: 546b62830af144bc8b46788d2e0fd00496838939
2018-02-10 04:31:44 +03:00
F821, # undefined name name
F822, # undefined name name in __all__
F823, # local variable name … referenced before assignment
F831, # duplicate argument name in function definition
flake8: resolve some F checks Summary: Solves issues below: ``` hgext/backups.py:18:1: F811 redefinition of unused 'registrar' from line 17 hgext/catnotate.py:1:1: F811 redefinition of unused 'util' from line 1 hgext/remotenames.py:57:5: F811 redefinition of unused 'registrar' from line 34 hgsubversion/setup.py:103:5: F401 'mercurial' imported but unused hgsubversion/setup.py:109:5: F401 'hgsubversion.svnwrap.svn_swig_wrapper' imported but unused i18n/polib.py:1281:29: F841 local variable 'exc' is assigned to but never used (Python 2) i18n/polib.py:1427:13: F841 local variable 'typ' is assigned to but never used i18n/polib.py:28:1: F401 'sys' imported but unused mercurial/manifest.py:411:5: F811 redefinition of unused '_lazymanifest' from line 168 mercurial/posix.py:419:5: F811 redefinition of unused 'normcasefallback' from line 362 mercurial/posix.py:425:5: F811 redefinition of unused 'checkexec' from line 167 mercurial/posix.py:431:5: F811 redefinition of unused 'checklink' from line 234 mercurial/pycompat.py:29:5: F401 'http.cookiejar as cookielib' imported but unused mercurial/pycompat.py:30:5: F401 'http.client as httplib' imported but unused mercurial/pycompat.py:31:5: F401 'pickle' imported but unused mercurial/pycompat.py:33:5: F401 'socketserver' imported but unused mercurial/pycompat.py:34:5: F401 'xmlrpc.client as xmlrpclib' imported but unused mercurial/statprof.py:573:36: F812 list comprehension redefines 'parent' from line 562 (Python 2) mercurial/util.py:1076:5: F811 redefinition of unused 'nogc' from line 1051 mercurial/util.py:3221:5: F811 redefinition of unused 'dirs' from line 3184 tests/silenttestrunner.py:24:5: F811 redefinition of unused 'main' from line 6 tests/test-context.py:90:1: F811 redefinition of unused 'scmutil' from line 4 tests/test-fb-hgext-cstore-treemanifest.py:146:5: F811 redefinition of unused 'testDeeplyNested' from line 134 tests/test-fb-hgext-extutil.py:46:5: F811 redefinition of unused 'testbgcommandfailure' from line 37 tests/test_hgsubversion_util.py:47:1: F811 redefinition of unused 'svnwrap' from line 31 (Python 2) tests/test_hgsubversion_util.py:49:1: F811 redefinition of unused 'svnwrap' from line 47 (Python 2) ``` Reviewed By: ryanmce Differential Revision: D6934533 fbshipit-source-id: 8b51851a76fec88bb59107ed05a901d42c7326f8
2018-02-10 04:31:41 +03:00
F841, # local variable name is assigned to but never used
E101, # indentation contains mixed spaces and tabs
E112, # expected an indented block
E113, # unexpected indentation
E133, # closing bracket is missing indentation
E223, # tab before operator
E224, # tab after operator
E242, # tab after ,
E272, # multiple spaces before keyword
E273, # tab after keyword
E274, # tab before keyword
E304, # blank lines found after function decorator
# BLACK can make lines longer than 80 characters
# E501, # line too long (82 > 79 characters)
E703, # statement ends with a semicolon
E704, # multiple statements on one line (def)
E711, # comparison to None should be if cond is None:
E712, # comparison to True should be if cond is True: or if cond:
E714, # test for object identity should be is not
E742, # do not define classes named l, O, or I
E743, # do not define functions named l, O, or I
E901, # SyntaxError or IndentationError
E902, # IOError
W191, # indentation contains tabs
W291, # trailing whitespace
W292, # no newline at end of file
W504, # line break after binary operator
W601, # .has_key() is deprecated, use in
W602, # deprecated form of raising exception
W603, # <> is deprecated, use !=
W604, # backticks are deprecated, use repr()
W605, # invalid escape sequence x
# dageval defined names
builtins =
ancestors,
children,
draft,
gcaall,
heads,
headsancestors,
obsolete,
parents,
public,
roots,
only,