Permalink
Browse files

Run flake8 on opy/ too.

Fix all the lint errors, mainly unused imports.  Had to exclude a couple
files.
  • Loading branch information...
Andy Chu
Andy Chu committed Mar 18, 2018
1 parent a530f30 commit efe4efb76191004b5ddbfa11122de6ed3fcb4a1a
View
@@ -23,6 +23,8 @@ def testFoo(self):
print(sys.modules[lex_mode_e.__module__])
print(sys.modules[lex_mode_e.__module__].__file__)
print(callgraph)
if __name__ == '__main__':
unittest.main()
View
@@ -1,19 +1,20 @@
import imp
import os
import marshal
import struct
import sys
from cStringIO import StringIO
from . import ast, syntax
from .visitor import walk
from .transformer import parse
from . import pyassem, misc, future, symbols
from .consts import SC_LOCAL, SC_GLOBAL_IMPLICIT, SC_GLOBAL_EXPLICIT, \
SC_FREE, SC_CELL
from .consts import (CO_VARARGS, CO_VARKEYWORDS, CO_NEWLOCALS,
CO_NESTED, CO_GENERATOR, CO_FUTURE_DIVISION,
CO_FUTURE_ABSIMPORT, CO_FUTURE_WITH_STATEMENT, CO_FUTURE_PRINT_FUNCTION)
from .consts import (
SC_LOCAL, SC_GLOBAL_IMPLICIT, SC_GLOBAL_EXPLICIT, SC_FREE, SC_CELL)
# NOTE: removed CO_NESTED because it is unused
from .consts import (
CO_VARARGS, CO_VARKEYWORDS, CO_NEWLOCALS,
CO_GENERATOR, CO_FUTURE_DIVISION,
CO_FUTURE_ABSIMPORT, CO_FUTURE_WITH_STATEMENT, CO_FUTURE_PRINT_FUNCTION)
from .pyassem import TupleArg
# XXX The version-specific code can go, since this code only works with 2.x.
@@ -7,7 +7,6 @@
import sys
import symtable
import unittest
from . import symbols
from . import transformer
View
@@ -9,7 +9,6 @@
errors.
"""
from . import ast
from .visitor import walk
View
@@ -1,4 +1,3 @@
from . import ast
# XXX should probably rename ASTVisitor to ASTWalker
# XXX can it be made even more generic?
View
@@ -19,7 +19,7 @@
tools/dumppyc.py, which came with the 'compiler2' package.
"""
import collections, cStringIO, dis, marshal, struct, sys, time, types
import collections, dis, marshal, struct, sys, time, types
from ..compiler2 import consts
@@ -6,7 +6,7 @@
import compiler as stdlib_comp
import imp
import os
#import os
import marshal
import struct
import sys
View
@@ -10,7 +10,7 @@
import os
import sys
import marshal
import logging
#import logging
# Like oil.py, set PYTHONPATH internally? So symlinks work?
# Actually '.' is implicitly in PYTHONPATH, so we don't need it.
@@ -19,12 +19,12 @@
#sys.path.append(os.path.join(this_dir))
from .pgen2 import driver, pgen, grammar
from .pgen2 import token, tokenize
from .pgen2 import tokenize
from . import pytree
from .compiler2 import transformer
from .compiler2 import pycodegen
from .compiler2 import opcode
#from .compiler2 import opcode
from .misc import inspect_pyc
View
@@ -13,14 +13,12 @@
__author__ = "Guido van Rossum <guido@python.org>"
__all__ = ["Driver", "load_grammar"]
__all__ = ["Driver"]
# Python imports
import codecs
import io
import os
import logging
import sys
# Pgen imports
from . import grammar, parse, token, tokenize
View
@@ -13,13 +13,11 @@
"""
# Python imports
import cStringIO
import collections
import pickle
import marshal
# Local imports
from . import token, tokenize
from . import token
class Grammar(object):
View
@@ -13,8 +13,7 @@
__author__ = "Guido van Rossum <guido@python.org>"
import sys
import warnings
from io import StringIO
import cStringIO
HUGE = 0x7FFFFFFF # maximum repeat count, default max
@@ -687,7 +686,7 @@ def generate_matches(self, nodes):
# implementations don't have this nasty bug in the first place.
if hasattr(sys, "getrefcount"):
save_stderr = sys.stderr
sys.stderr = StringIO()
sys.stderr = cStringIO.StringIO()
try:
for count, r in self._recursive_matches(nodes, 0):
if self.name:
@@ -1,2 +1,3 @@
from __future__ import print_function
import sys
print("hi from Python 2", file=sys.stderr)
View
@@ -95,12 +95,18 @@ bin-flake8() {
}
flake8-all() {
local -a dirs=(asdl bin core osh)
local -a dirs=(asdl bin core osh opy)
# astgen.py has a PROLOGUE which must have unused imports!
# opcode.py triggers a flake8 bug? Complains about def_op() when it is
# defined.
local -a exclude=(
--exclude 'opy/_regtest,opy/byterun,opy/tools/astgen.py,opy/compiler2/opcode.py')
# Step 1: Stop the build if there are Python syntax errors, undefined names,
# unused imports
local fatal_errors='E901,E999,F821,F822,F823,F401'
bin-flake8 "${dirs[@]}" \
bin-flake8 "${dirs[@]}" "${exclude[@]}" \
--count --select "$fatal_errors" --show-source --statistics
# Make unused variable fatal. Hm there are some I want.
@@ -119,8 +125,8 @@ flake8-all() {
local ignored_for_now='W291,E501,E303'
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
bin-flake8 "${dirs[@]}" \
--ignore="$ignored,$ignored_for_now" \
bin-flake8 "${dirs[@]}" "${exclude[@]}" \
--ignore "$ignored,$ignored_for_now" \
--count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
}

0 comments on commit efe4efb

Please sign in to comment.