Skip to content

Commit fe1c76c

Browse files
committed
Fix #27 flake8 F821 undefined name
Some of these warning are real bugs.
1 parent 8e2b506 commit fe1c76c

10 files changed

Lines changed: 29 additions & 21 deletions

File tree

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ exclude = .git,docs/europython/*.py,ez_setup.py
1919
; F402 import 'name' shadowed by loop variable
2020
; F403 'from module import *' used; unable to detect undefined names
2121
; F812 list comprehension redefines 'name' from line 1402
22-
; F821 undefined name
2322
; F822 undefined name in __all__
2423
; W291 trailing whitespace
2524
; W293 blank line contains whitespace
2625
; W391 blank line at end of file
2726
; W603 '<>' is deprecated, use '!='
28-
ignore = E123,E124,E226,E401,E502,F402,F403,F812,F821,F822,W291,W293,W391,W603
27+
ignore = E123,E124,E226,E401,E502,F402,F403,F812,F822,W291,W293,W391,W603
2928

3029
[pudge]
3130
theme = pythonpaste.org

sqlobject/col.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def __get__(self, obj, type=None):
375375
if columns is None:
376376
obj.sqlmeta.loadValues()
377377
try:
378-
return columns[name]
378+
return columns[name] # noqa
379379
except KeyError:
380380
return obj.sqlmeta.loadColumn(self)
381381
else:

sqlobject/dbconnection.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,12 +1040,13 @@ def registerConnection(self, schemes, builder):
10401040

10411041
def registerConnectionInstance(self, inst):
10421042
if inst.name:
1043-
assert not inst.name in self.instanceNames \
1044-
or self.instanceNames[inst.name] is cls, \
1045-
"A instance has already been registered " \
1046-
"with the name %s" % inst.name
1043+
assert (not inst.name in self.instanceNames
1044+
or self.instanceNames[inst.name] is cls # noqa
1045+
), ("A instance has already been registered "
1046+
"with the name %s" % inst.name)
10471047
assert inst.name.find(':') == -1, \
1048-
"You cannot include ':' in your class names (%r)" % cls.name
1048+
"You cannot include ':' " \
1049+
"in your class names (%r)" % cls.name # noqa
10491050
self.instanceNames[inst.name] = inst
10501051

10511052
def connectionForURI(self, uri, oldUri=False, **args):

sqlobject/events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ def sort_name(value):
272272

273273
_real_dispatcher_send = dispatcher.send
274274
_real_dispatcher_sendExact = dispatcher.sendExact
275-
_real_dispatcher_disconnect = dispatcher.disconnect
276275
_real_dispatcher_connect = dispatcher.connect
276+
_real_dispatcher_disconnect = dispatcher.disconnect
277277
_debug_enabled = False
278278

279279

@@ -314,7 +314,7 @@ def _debug_disconnect(receiver, signal=dispatcher.Any, sender=dispatcher.Any,
314314
weak=True):
315315
print("disconnecting %s from %s signal %s" % (
316316
nice_repr(receiver), nice_repr(signal), nice_repr(sender)))
317-
return disconnect(receiver, signal, sender, weak)
317+
return _real_dispatcher_disconnect(receiver, signal, sender, weak)
318318

319319

320320
def fmt_args(*arguments, **name):

sqlobject/manager/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def run(self):
293293
os.path.basename(self.invoked_as),
294294
self.command_name)
295295
if self.description:
296-
self.parser.description = description
296+
self.parser.description = self.description
297297
self.options, self.args = self.parser.parse_args(self.raw_args)
298298
if (getattr(self.options, 'simulate', False)
299299
and not self.options.verbose):
@@ -1102,7 +1102,7 @@ def strip_comments(self, sql):
11021102
def base_dir(self):
11031103
base = self.options.output_dir
11041104
if base is None:
1105-
base = CONFIG.get('sqlobject_history_dir', '.')
1105+
base = CONFIG.get('sqlobject_history_dir', '.') # noqa
11061106
if not os.path.exists(base):
11071107
print('Creating history directory %s' %
11081108
self.shorten_filename(base))

sqlobject/maxdb/maxdbconnection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
host=hostname, database=dbname,
1414
user=user_name, password=user_password, autoCommit=1, debug=1)
1515
"""
16+
17+
import os
1618
from sqlobject.dbconnection import DBAPI
1719
from sqlobject import col
1820

@@ -311,7 +313,7 @@ def guessClass(self, t, flength, fscale=None):
311313
elif t in self._dateTypes:
312314
return col.DateTimeCol, {}
313315
elif t == 'FIXED':
314-
return CurrencyCol, {'size': flength,
315-
'precision': fscale}
316+
return col.CurrencyCol, {'size': flength,
317+
'precision': fscale}
316318
else:
317319
return col.Col, {}

sqlobject/mssql/mssqlconnection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def addColumn(self, tableName, column):
216216
column.mssqlCreateSQL(self)))
217217

218218
def delColumn(self, sqlmeta, column):
219-
self.query('ALTER TABLE %s DROP COLUMN %s' % (tableName.table,
219+
self.query('ALTER TABLE %s DROP COLUMN %s' % (sqlmeta.table,
220220
column.dbName))
221221

222222
# precision and scale is gotten from column table so that we can create
@@ -288,7 +288,9 @@ def _setAutoCommit(self, conn, auto):
288288
option = "OFF"
289289
c = conn.cursor()
290290
c.execute("SET AUTOCOMMIT " + option)
291-
conn.setconnectoption(SQL.AUTOCOMMIT, option)
291+
# from mx.ODBC.Windows import SQL
292+
# connection.setconnectoption(
293+
# SQL.AUTOCOMMIT, SQL.AUTOCOMMIT_ON if auto else SQL.AUTOCOMMIT_OFF)
292294

293295
# precision and scale is needed for decimal columns
294296
def guessClass(self, t, size, precision, scale):

sqlobject/sqlbuilder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ def components(self):
360360
return [self.expr]
361361

362362
def execute(self, executor):
363+
prefix = self.prefix
363364
expr = execute(self.expr, executor)
364365
if prefix == "+":
365366
return expr

sqlobject/util/csvimport.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@
5555
Lines that begin with ``[comment]`` are ignored.
5656
"""
5757

58+
import csv
5859
from datetime import datetime, date, timedelta
5960
import os
60-
import csv
61+
import time
6162
import types
6263

6364
__all__ = ['load_csv_from_directory',
@@ -199,7 +200,8 @@ def load_csv(csvreader, allow_python=True, default_type=DEFAULT_TYPE,
199200
"for this file (line: %r)" % row)
200201

201202
if current_headers is None:
202-
current_headers = _parse_headers(row, default_type)
203+
current_headers = _parse_headers(row, default_type,
204+
allow_python=allow_python)
203205
continue
204206

205207
if row[0] == '[comment]':
@@ -225,7 +227,7 @@ def load_csv(csvreader, allow_python=True, default_type=DEFAULT_TYPE,
225227
return results
226228

227229

228-
def _parse_headers(header_row, default_type):
230+
def _parse_headers(header_row, default_type, allow_python=True):
229231
headers = []
230232
for name in header_row:
231233
original_name = name
@@ -359,7 +361,7 @@ def parse_bool(v):
359361
elif v in ('n', 'no', 'f', 'false', 'off', '0'):
360362
return False
361363
raise ValueError(
362-
"Value is not boolean-like: %r" % value)
364+
"Value is not boolean-like: %r" % v)
363365

364366
register_coercer('bool', parse_bool)
365367
register_coercer('boolean', parse_bool)

sqlobject/util/moduleloader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import sys
21
import imp
2+
import os
3+
import sys
34

45

56
def load_module(module_name):

0 commit comments

Comments
 (0)