Permalink
Browse files

Fix most unused variable errors.

Get rid of pep8 functions, because flake8 is a superset of pep8.
  • Loading branch information...
Andy Chu
Andy Chu committed Feb 2, 2018
1 parent 1dee824 commit 9376827eb81e10d9e892728be3f69adb033e5765
Showing with 21 additions and 32 deletions.
  1. +0 −1 core/braces.py
  2. +2 −2 core/builtin.py
  3. +1 −5 core/cmd_exec.py
  4. +2 −2 core/expr_eval.py
  5. +0 −1 core/process.py
  6. +0 −1 core/state.py
  7. +0 −1 core/util.py
  8. +1 −1 core/word_eval.py
  9. +15 −18 test/lint.sh
View
@@ -221,7 +221,6 @@ def _BraceExpand(parts):
return [parts]
elif num_alts == 1:
out = []
suffix = parts[first_alt_index+1 : ]
return _BraceExpandOne(parts, first_alt_index, [suffix])
View
@@ -495,7 +495,7 @@ def Shift(argv, mem):
n = int(argv[0])
except IndexError:
n = 1
except ValueError as e:
except ValueError:
print("Invalid shift argument %r" % argv[1], file=sys.stderr)
return 1 # runtime error
@@ -655,7 +655,7 @@ def Export(argv, mem):
raise args.UsageError('export: Invalid variable name %r' % name)
# NOTE: bash doesn't care if it wasn't found.
_ = mem.ClearFlag(name, var_flags_e.Exported, scope_e.Dynamic)
mem.ClearFlag(name, var_flags_e.Exported, scope_e.Dynamic)
else:
for arg in argv[i:]:
parts = arg.split('=', 1)
View
@@ -267,8 +267,6 @@ def _Exec(self, argv):
return 0
def _RunBuiltin(self, builtin_id, argv):
restore_fd_state = True
# NOTE: Builtins don't need to know their own name.
argv = argv[1:]
@@ -634,7 +632,6 @@ def _SetSourceLocation(self, span_id):
# TODO: This API should be simplified
line_span = self.arena.GetLineSpan(span_id)
line_id = line_span.line_id
line = self.arena.GetLine(line_id)
source_name, line_num = self.arena.GetDebugInfo(line_id)
self.mem.SetSourceLocation(source_name, line_num)
@@ -650,7 +647,7 @@ def _Dispatch(self, node, fork_external):
# command.
self.check_command_sub_status = False
argv0 = None # for error message
#argv0 = None # for error message
check_errexit = False # for errexit
if node.tag == command_e.SimpleCommand:
@@ -759,7 +756,6 @@ def _Dispatch(self, node, fork_external):
status = 0 if i != 0 else 1
elif node.tag == command_e.Assignment:
pairs = []
flags = word_compile.ParseAssignFlags(node.flags)
if node.keyword == Id.Assign_Local:
View
@@ -485,14 +485,14 @@ def Eval(self, node):
if op_id in (Id.BoolUnary_h, Id.BoolUnary_L):
try:
mode = os.lstat(s).st_mode
except OSError as e:
except OSError:
return False
return stat.S_ISLNK(mode)
try:
mode = os.stat(s).st_mode
except OSError as e:
except OSError:
# TODO: Signal extra debug information?
#self._AddErrorContext("Error from stat(%r): %s" % (s, e))
return False
View
@@ -202,7 +202,6 @@ def Push(self, redirects, waiter):
self.stack.append(new_frame)
self.cur_frame = new_frame
ok = True
for r in redirects:
#log('apply %s', r)
if not self._ApplyRedirect(r, waiter):
View
@@ -528,7 +528,6 @@ def _FindCellAndNamespace(self, name, lookup_mode, is_read=False):
namespace: The namespace it should be set to or deleted from.
"""
if lookup_mode == scope_e.Dynamic:
found = False
for i in range(len(self.var_stack) - 1, -1, -1):
frame = self.var_stack[i]
if frame.readonly and not is_read:
View
@@ -18,7 +18,6 @@
import pwd
import sys
import os
if not os.getenv('_OVM_DEPS'):
import inspect
import types
View
@@ -706,7 +706,7 @@ def _EvalWordToParts(self, word, quoted, part_vals):
"Expected CompoundWord, got %s" % word
for p in word.parts:
v = self._EvalWordPart(p, part_vals, quoted=quoted)
self._EvalWordPart(p, part_vals, quoted=quoted)
def EvalWordToString(self, word, do_fnmatch=False, decay=False):
"""
View
@@ -58,21 +58,6 @@ bin-pep8() {
~/.local/bin/pep8 "$@"
}
# disable:
# E226: missing whitespace around arithmetic -- I want to do i+1
# E302: expected two blank lines, found 1 (sometimes one is useful).
# E265: Although I agree with this style, some comments don't start with '# '
# E111,E114: we use 2 space indents, not 4
oil-pep8() {
# These could be enabled.
local temp=W291,E501,E303 # trailing whitespace, line too long, blank lines
bin-pep8 --ignore E125,E701,E241,E121,E111,E114,E128,E262,E226,E302,E265,$temp "$@"
}
pep8-all() {
oil-pep8 {asdl,bin,core,osh}/*.py "$@"
}
# Language independent
find-tabs() {
# benchmarks/testdata should be excluded
@@ -100,12 +85,24 @@ bin-flake8() {
flake8-all() {
local -a dirs=(asdl bin core osh)
# Step 1: Stop the build if there are Python syntax errors or undefined names
# 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[@]}" \
--count --select=E901,E999,F821,F822,F823,F401 --show-source --statistics
--count --select "$fatal_errors" --show-source --statistics
# Make unused variable fatal. Hm there are some I want.
#scripts/count.sh oil-osh-files | grep -F '.py' | xargs $0 bin-flake8 --select F841
# Step 2: Style errors as warnings.
local ignored='E125,E701,E241,E121,E111,E114,E128,E262,E226,E302,E265,E290,E202,E203,C901'
# disable:
# E226: missing whitespace around arithmetic -- I want to do i+1
# E302: expected two blank lines, found 1 (sometimes one is useful).
# E265: Although I agree with this style, some comments don't start with '# '
# E111,E114: we use 2 space indents, not 4
local ignored='E125,E701,E241,E121,E111,E114,E128,E262,E226,E302,E265,E290,E202,E203,C901,E261'
# trailing whitespace, line too long, blank lines
local ignored_for_now='W291,E501,E303'

0 comments on commit 9376827

Please sign in to comment.