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
This commit is contained in:
parent
5a46a5bbed
commit
bfeabc58b4
@ -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),
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
@ -24,7 +24,7 @@ import gertty.search
|
||||
from tokenizer import tokens
|
||||
|
||||
def SearchParser():
|
||||
precedence = (
|
||||
precedence = ( # NOQA
|
||||
('left', 'NOT', 'NEG'),
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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 ''
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user