summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-05-30 11:31:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-06-20 13:50:41 -0400
commit190e0139e834e4271268652e058c280787ae69eb (patch)
tree21e93907a58cd2f390f687ddc5e0c1da1eb25454 /examples
parentff8e7732b9f656f8cea05544660c18d57dd37864 (diff)
downloadsqlalchemy-190e0139e834e4271268652e058c280787ae69eb.tar.gz
Enable F841
This is a very useful assertion which prevents unused variables from being set up allows code to be more readable and sometimes even more efficient. test suites seem to be where the most problems are and there do not seem to be documentation examples that are using this, or at least the linter is not taking effect within rst blocks. Change-Id: I2b3341d8dd14da34879d8425838e66a4b9f8e27d
Diffstat (limited to 'examples')
-rw-r--r--examples/elementtree/adjacency_list.py3
-rw-r--r--examples/elementtree/optimized_al.py2
-rw-r--r--examples/performance/__init__.py4
-rw-r--r--examples/performance/large_resultsets.py14
-rw-r--r--examples/performance/single_inserts.py4
5 files changed, 11 insertions, 16 deletions
diff --git a/examples/elementtree/adjacency_list.py b/examples/elementtree/adjacency_list.py
index 0f53e0012..0a5a922d0 100644
--- a/examples/elementtree/adjacency_list.py
+++ b/examples/elementtree/adjacency_list.py
@@ -93,6 +93,7 @@ class Document(object):
self.filename = name
self.element = element
+
# PART IV - Persistence Mapping
# Node class. a non-public class which will represent the DB-persisted
@@ -230,8 +231,6 @@ ElementTree.dump(d.element)
def find_document(path, compareto):
- j = documents
- prev_elements = None
query = session.query(Document)
attribute = "_root"
for i, match in enumerate(
diff --git a/examples/elementtree/optimized_al.py b/examples/elementtree/optimized_al.py
index b089a0170..0ba2d1ea4 100644
--- a/examples/elementtree/optimized_al.py
+++ b/examples/elementtree/optimized_al.py
@@ -239,8 +239,6 @@ ElementTree.dump(d.element)
def find_document(path, compareto):
- j = documents
- prev_elements = None
query = session.query(Document)
first = True
for i, match in enumerate(
diff --git a/examples/performance/__init__.py b/examples/performance/__init__.py
index f1f59026c..c6244554f 100644
--- a/examples/performance/__init__.py
+++ b/examples/performance/__init__.py
@@ -334,7 +334,7 @@ class Profiler(object):
if len(sys.argv) > 1:
potential_name = sys.argv[1]
try:
- suite = __import__(__name__ + "." + potential_name)
+ __import__(__name__ + "." + potential_name)
except ImportError:
pass
@@ -382,7 +382,7 @@ class Profiler(object):
args.profile = args.profile or args.dump or args.runsnake
if cls.name is None:
- suite = __import__(__name__ + "." + args.name)
+ __import__(__name__ + "." + args.name)
Profiler(args).run()
diff --git a/examples/performance/large_resultsets.py b/examples/performance/large_resultsets.py
index a5f99a283..b7b96453d 100644
--- a/examples/performance/large_resultsets.py
+++ b/examples/performance/large_resultsets.py
@@ -64,7 +64,7 @@ def test_orm_full_objects_list(n):
"""Load fully tracked ORM objects into one big list()."""
sess = Session(engine)
- objects = list(sess.query(Customer).limit(n))
+ list(sess.query(Customer).limit(n))
@Profiler.profile
@@ -108,7 +108,7 @@ def test_core_fetchall(n):
with engine.connect() as conn:
result = conn.execute(Customer.__table__.select().limit(n)).fetchall()
for row in result:
- data = row["id"], row["name"], row["description"]
+ row["id"], row["name"], row["description"]
@Profiler.profile
@@ -124,7 +124,7 @@ def test_core_fetchmany_w_streaming(n):
if not chunk:
break
for row in chunk:
- data = row["id"], row["name"], row["description"]
+ row["id"], row["name"], row["description"]
@Profiler.profile
@@ -138,7 +138,7 @@ def test_core_fetchmany(n):
if not chunk:
break
for row in chunk:
- data = row["id"], row["name"], row["description"]
+ row["id"], row["name"], row["description"]
@Profiler.profile
@@ -183,13 +183,11 @@ def _test_dbapi_raw(n, make_objects):
if make_objects:
for row in cursor.fetchall():
# ensure that we fully fetch!
- customer = SimpleCustomer(
- id_=row[0], name=row[1], description=row[2]
- )
+ SimpleCustomer(id_=row[0], name=row[1], description=row[2])
else:
for row in cursor.fetchall():
# ensure that we fully fetch!
- data = row[0], row[1], row[2]
+ row[0], row[1], row[2]
conn.close()
diff --git a/examples/performance/single_inserts.py b/examples/performance/single_inserts.py
index 428eb5c41..2dd87d5b6 100644
--- a/examples/performance/single_inserts.py
+++ b/examples/performance/single_inserts.py
@@ -164,7 +164,7 @@ def _test_dbapi_raw(n, connect):
conn = engine.pool._creator()
cursor = conn.cursor()
cursor.execute(sql, arg)
- lastrowid = cursor.lastrowid
+ cursor.lastrowid
conn.commit()
conn.close()
else:
@@ -172,7 +172,7 @@ def _test_dbapi_raw(n, connect):
conn = engine.raw_connection()
cursor = conn.cursor()
cursor.execute(sql, arg)
- lastrowid = cursor.lastrowid
+ cursor.lastrowid
conn.commit()
conn.close()