Browse Source

flake8: Fix F821,F841

This commit fixes the following flake8 issues:

F821 undefined name 'name'
F841 local variable 'name' is assigned to but never used

It also silences the false-positives caused by parser.py and
tokenizer.py.

Change-Id: Icdc42f47f5f1f383054d8dfdeed6509fc478637b
changes/91/391991/1
Christoph Gysin 7 years ago
committed by James E. Blair
parent
commit
bfeabc58b4
  1. 2
      gertty/alembic/versions/312cd5a9f878_add_can_submit_column.py
  2. 6
      gertty/alembic/versions/3d429503a29a_add_draft_fields.py
  3. 2
      gertty/app.py
  4. 2
      gertty/search/parser.py
  5. 9
      gertty/search/tokenizer.py
  6. 22
      gertty/sync.py
  7. 1
      gertty/view/change.py
  8. 6
      gertty/view/change_list.py
  9. 2
      tox.ini

2
gertty/alembic/versions/312cd5a9f878_add_can_submit_column.py

@ -25,7 +25,7 @@ def upgrade():
conn = op.get_bind()
q = sa.text('update revision set can_submit=:submit')
res = conn.execute(q, submit=False)
conn.execute(q, submit=False)
sqlite_alter_columns('revision', [
sa.Column('can_submit', sa.Boolean(), nullable=False),

6
gertty/alembic/versions/3d429503a29a_add_draft_fields.py

@ -25,9 +25,9 @@ def upgrade():
op.add_column('approval', sa.Column('draft', sa.Boolean()))
conn = op.get_bind()
res = conn.execute("update message set draft=pending")
res = conn.execute("update comment set draft=pending")
res = conn.execute("update approval set draft=pending")
conn.execute("update message set draft=pending")
conn.execute("update comment set draft=pending")
conn.execute("update approval set draft=pending")
sqlite_alter_columns('message', [
sa.Column('draft', sa.Boolean(), index=True, nullable=False),

2
gertty/app.py

@ -472,7 +472,7 @@ class App(object):
continue
if not filename:
filename = '/'.join(path)
m = trailing_filename_re.match(filename)
m = self.trailing_filename_re.match(filename)
if m:
filename = filename[:0-len(m.group(1))]
path = None

2
gertty/search/parser.py

@ -24,7 +24,7 @@ import gertty.search
from tokenizer import tokens
def SearchParser():
precedence = (
precedence = ( # NOQA
('left', 'NOT', 'NEG'),
)

9
gertty/search/tokenizer.py

@ -68,9 +68,10 @@ tokens = [
] + operators.values()
def SearchTokenizer():
t_LPAREN = r'\('
t_RPAREN = r'\)'
t_NEG = r'!'
t_LPAREN = r'\(' # NOQA
t_RPAREN = r'\)' # NOQA
t_NEG = r'!' # NOQA
t_ignore = ' \t' # NOQA (and intentionally not using r'' due to tab char)
def t_OP(t):
r'[a-zA-Z_][a-zA-Z_]*:'
@ -150,8 +151,6 @@ def SearchTokenizer():
r'\n+'
t.lexer.lineno += len(t.value)
t_ignore = ' \t'
def t_error(t):
print "Illegal character '%s'" % t.value[0]
t.lexer.skip(1)

22
gertty/sync.py

@ -35,7 +35,7 @@ import requests
import requests.utils
import gertty.version
import gertty.gitrepo
from gertty import gitrepo
HIGH_PRIORITY=0
NORMAL_PRIORITY=1
@ -402,9 +402,7 @@ class SyncChangeByCommitTask(Task):
return '<SyncChangeByCommitTask %s>' % (self.commit,)
def run(self, sync):
app = sync.app
with app.db.getSession() as session:
query = 'commit:%s' % self.commit
query = 'commit:%s' % self.commit
changes = sync.get('changes/?q=%s' % query)
self.log.debug('Query: %s ' % (query,))
for c in changes:
@ -420,9 +418,7 @@ class SyncChangeByNumberTask(Task):
return '<SyncChangeByNumberTask %s>' % (self.number,)
def run(self, sync):
app = sync.app
with app.db.getSession() as session:
query = '%s' % self.number
query = '%s' % self.number
changes = sync.get('changes/?q=%s' % query)
self.log.debug('Query: %s ' % (query,))
for c in changes:
@ -738,7 +734,7 @@ class CheckReposTask(Task):
try:
missing = False
try:
repo = app.getRepo(project.name)
app.getRepo(project.name)
except gitrepo.GitCloneError:
missing = True
if missing or app.fetch_missing_refs:
@ -922,9 +918,9 @@ class ChangeCommitMessageTask(Task):
revision.pending_message = False
data = dict(message=revision.message)
# Inside db session for rollback
ret = sync.post('changes/%s/revisions/%s/message' %
(revision.change.id, revision.commit),
data)
sync.post('changes/%s/revisions/%s/message' %
(revision.change.id, revision.commit),
data)
change_id = revision.change.id
sync.submitTask(SyncChangeTask(change_id, priority=self.priority))
@ -942,8 +938,8 @@ class UploadReviewTask(Task):
with app.db.getSession() as session:
message = session.getMessage(self.message_key)
if message is None:
self.log.debug("Message %s for change %s has already been uploaded" % (
self.message_key, change.id))
self.log.debug("Message %s has already been uploaded" % (
self.message_key))
return
change = message.revision.change
if not change.held:

1
gertty/view/change.py

@ -541,7 +541,6 @@ class ChangeView(urwid.WidgetWrap):
return True
def refresh(self):
change_info = []
with self.app.db.getSession() as session:
change = session.getChange(self.change_key)
self.topic = change.topic or ''

6
gertty/view/change_list.py

@ -33,7 +33,6 @@ class ThreadStack(object):
self.stack.append([change, children])
def pop(self):
change = None
while self.stack:
if self.stack[-1][1]:
# handle children at the tip
@ -95,7 +94,6 @@ class ChangeRow(urwid.Button):
else:
subject = change.subject
flag = ' '
color = None
if change.starred:
flag = '*'
style = 'starred-change'
@ -440,7 +438,7 @@ class ChangeListView(urwid.WidgetWrap):
return None
pos = self.listbox.focus_position
change_key = self.listbox.body[pos].change_key
held = self.toggleHeld(change_key)
self.toggleHeld(change_key)
row = self.change_rows[change_key]
with self.app.db.getSession() as session:
change = session.getChange(change_key)
@ -451,7 +449,7 @@ class ChangeListView(urwid.WidgetWrap):
return None
pos = self.listbox.focus_position
change_key = self.listbox.body[pos].change_key
starred = self.toggleStarred(change_key)
self.toggleStarred(change_key)
row = self.change_rows[change_key]
with self.app.db.getSession() as session:
change = session.getChange(change_key)

2
tox.ini

@ -31,6 +31,6 @@ deps = flake8
commands = {posargs}
[flake8]
ignore = W,E,F401,F403,F821,F841
ignore = W,E,F401,F403
show-source = True
exclude = .venv,.tox,dist,doc,build,*.egg
Loading…
Cancel
Save