summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 01:19:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 18:23:11 -0500
commit1e278de4cc9a4181e0747640a960e80efcea1ca9 (patch)
tree13d0c035807613bfa07e734acad79b9c843cb8b0 /lib/sqlalchemy/engine/base.py
parent1e1a38e7801f410f244e4bbb44ec795ae152e04e (diff)
downloadsqlalchemy-1e278de4cc9a4181e0747640a960e80efcea1ca9.tar.gz
Post black reformatting
Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r--lib/sqlalchemy/engine/base.py49
1 files changed, 27 insertions, 22 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 75d03b744..c0979ecac 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -6,18 +6,23 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
from __future__ import with_statement
-"""Defines :class:`.Connection` and :class:`.Engine`.
+import contextlib
+import sys
-"""
+from .interfaces import Connectable
+from .interfaces import ExceptionContext
+from .util import _distill_params
+from .. import exc
+from .. import interfaces
+from .. import log
+from .. import util
+from ..sql import schema
+from ..sql import util as sql_util
-import sys
-from .. import exc, util, log, interfaces
-from ..sql import util as sql_util
-from ..sql import schema
-from .interfaces import Connectable, ExceptionContext
-from .util import _distill_params
-import contextlib
+"""Defines :class:`.Connection` and :class:`.Engine`.
+
+"""
class Connection(Connectable):
@@ -172,7 +177,7 @@ class Connection(Connectable):
def __enter__(self):
return self
- def __exit__(self, type, value, traceback):
+ def __exit__(self, type_, value, traceback):
self.close()
def execution_options(self, **opt):
@@ -321,7 +326,7 @@ class Connection(Connectable):
:ref:`schema_translating`
- """
+ """ # noqa
c = self._clone()
c._execution_options = c._execution_options.union(opt)
if self._has_events or self.engine._has_events:
@@ -892,15 +897,15 @@ class Connection(Connectable):
self.__can_reconnect = False
self.__transaction = None
- def scalar(self, object, *multiparams, **params):
+ def scalar(self, object_, *multiparams, **params):
"""Executes and returns the first column of the first row.
The underlying result/cursor is closed after execution.
"""
- return self.execute(object, *multiparams, **params).scalar()
+ return self.execute(object_, *multiparams, **params).scalar()
- def execute(self, object, *multiparams, **params):
+ def execute(self, object_, *multiparams, **params):
r"""Executes a SQL statement construct and returns a
:class:`.ResultProxy`.
@@ -959,12 +964,12 @@ class Connection(Connectable):
DBAPI-agnostic way, use the :func:`~.expression.text` construct.
"""
- if isinstance(object, util.string_types[0]):
- return self._execute_text(object, multiparams, params)
+ if isinstance(object_, util.string_types[0]):
+ return self._execute_text(object_, multiparams, params)
try:
- meth = object._execute_on_connection
+ meth = object_._execute_on_connection
except AttributeError:
- raise exc.ObjectNotExecutableError(object)
+ raise exc.ObjectNotExecutableError(object_)
else:
return meth(self, multiparams, params)
@@ -1698,8 +1703,8 @@ class Transaction(object):
def __enter__(self):
return self
- def __exit__(self, type, value, traceback):
- if type is None and self.is_active:
+ def __exit__(self, type_, value, traceback):
+ if type_ is None and self.is_active:
try:
self.commit()
except:
@@ -2005,8 +2010,8 @@ class Engine(Connectable, log.Identified):
def __enter__(self):
return self.conn
- def __exit__(self, type, value, traceback):
- if type is not None:
+ def __exit__(self, type_, value, traceback):
+ if type_ is not None:
self.transaction.rollback()
else:
self.transaction.commit()