summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-01-27 16:51:05 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-01-27 16:56:25 -0500
commitbfddff4c9f72adc5d326cee9783c77d358254837 (patch)
tree59f12a717a3b3659eee453683d7758dbe1a1db5d
parent0cc2695510c0f0b09328e4cdf8d3ae29ac7f7abd (diff)
downloadsqlalchemy-bfddff4c9f72adc5d326cee9783c77d358254837.tar.gz
Add pyproject
- Added pyproject.toml with black arguments - Updated black version in precommit hook - Reformatted the code Fixes: #5100 Closes: #5103 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5103 Pull-request-sha: 795fd5f896be4a07a2b18e6525674b815ac17593 Change-Id: I14eedbaa51fb531cbf90fcefe6a1e07c8a565625
-rw-r--r--.pre-commit-config.yaml3
-rw-r--r--lib/sqlalchemy/dialects/oracle/cx_oracle.py2
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py2
-rw-r--r--lib/sqlalchemy/testing/provision.py3
-rw-r--r--pyproject.toml2
-rw-r--r--test/dialect/postgresql/test_reflection.py8
-rw-r--r--test/ext/test_baked.py14
-rw-r--r--test/orm/inheritance/_poly_fixtures.py7
-rw-r--r--test/orm/inheritance/test_basic.py4
-rw-r--r--test/orm/test_bulk.py14
-rw-r--r--test/orm/test_cycles.py4
-rw-r--r--test/orm/test_lazy_relations.py2
-rw-r--r--test/orm/test_naturalpks.py4
-rw-r--r--test/orm/test_rel_fn.py4
-rw-r--r--test/orm/test_selectin_relations.py2
15 files changed, 40 insertions, 35 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e4427aa3a..af06dcd79 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,10 +2,9 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/python/black/
- rev: 19.3b0
+ rev: 19.10b0
hooks:
- id: black
- args: [-l 79]
- repo: https://github.com/sqlalchemyorg/zimports/
rev: master
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
index cb57bd4d8..b000a4615 100644
--- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py
+++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
@@ -1085,7 +1085,7 @@ class OracleDialect_cx_oracle(OracleDialect):
return tuple(int(x) for x in connection.connection.version.split("."))
def is_disconnect(self, e, connection, cursor):
- error, = e.args
+ (error,) = e.args
if isinstance(
e, (self.dbapi.InterfaceError, self.dbapi.DatabaseError)
) and "not connected" in str(e):
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index e8e79b230..82c619c85 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -3491,7 +3491,7 @@ class PGDialect(default.DefaultDialect):
util.warn("Could not parse CHECK constraint text: %r" % src)
sqltext = ""
else:
- sqltext = re.sub(r'^\((.+)\)$', r'\1', m.group(1))
+ sqltext = re.sub(r"^\((.+)\)$", r"\1", m.group(1))
entry = {"name": name, "sqltext": sqltext}
if m and m.group(2):
entry["dialect_options"] = {"not_valid": True}
diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py
index a412f0943..6e2e1ccf5 100644
--- a/lib/sqlalchemy/testing/provision.py
+++ b/lib/sqlalchemy/testing/provision.py
@@ -186,4 +186,5 @@ def temp_table_keyword_args(cfg, eng):
ComponentReflectionTest class in suite/test_reflection.py
"""
raise NotImplementedError(
- "no temp table keyword args routine for cfg: %s" % eng.url)
+ "no temp table keyword args routine for cfg: %s" % eng.url
+ )
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..a8f43fefd
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,2 @@
+[tool.black]
+line-length = 79
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index cc231933c..b410ca748 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -1535,10 +1535,10 @@ class ReflectionTest(fixtures.TestBase):
RETURN x > 0;
END;$BODY$;
"""
- sa.event.listen(meta, "before_create",
- sa.DDL(udf_create))
- sa.event.listen(meta, "after_drop",
- sa.DDL("DROP FUNCTION is_positive(integer)"))
+ sa.event.listen(meta, "before_create", sa.DDL(udf_create))
+ sa.event.listen(
+ meta, "after_drop", sa.DDL("DROP FUNCTION is_positive(integer)")
+ )
Table(
"pgsql_cc",
diff --git a/test/ext/test_baked.py b/test/ext/test_baked.py
index 01f0e267f..faf0ec533 100644
--- a/test/ext/test_baked.py
+++ b/test/ext/test_baked.py
@@ -1438,15 +1438,17 @@ class LazyLoaderTest(testing.AssertsCompiledSQL, BakedTest):
def test_simple_lazy_clause_no_race_on_generate(self):
User, Address = self._o2m_fixture()
- expr1, paramdict1 = (
- User.addresses.property._lazy_strategy._simple_lazy_clause
- )
+ (
+ expr1,
+ paramdict1,
+ ) = User.addresses.property._lazy_strategy._simple_lazy_clause
# delete the attr, as though a concurrent thread is also generating it
del User.addresses.property._lazy_strategy._simple_lazy_clause
- expr2, paramdict2 = (
- User.addresses.property._lazy_strategy._simple_lazy_clause
- )
+ (
+ expr2,
+ paramdict2,
+ ) = User.addresses.property._lazy_strategy._simple_lazy_clause
eq_(paramdict1, paramdict2)
diff --git a/test/orm/inheritance/_poly_fixtures.py b/test/orm/inheritance/_poly_fixtures.py
index aa428a5eb..2a3a5dcff 100644
--- a/test/orm/inheritance/_poly_fixtures.py
+++ b/test/orm/inheritance/_poly_fixtures.py
@@ -316,9 +316,10 @@ class _PolymorphicFixtureBase(fixtures.MappedTest, AssertsCompiledSQL):
mapper(Machine, machines)
- person_with_polymorphic, manager_with_polymorphic = (
- cls._get_polymorphics()
- )
+ (
+ person_with_polymorphic,
+ manager_with_polymorphic,
+ ) = cls._get_polymorphics()
mapper(
Person,
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index 084563972..ebb485156 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -3384,7 +3384,7 @@ class DiscriminatorOrPkNoneTest(fixtures.DeclarativeMappedTest):
eq_(row, (Parent(id=2), None))
def test_pk_not_null_discriminator_null_from_base(self):
- A, = self.classes("A")
+ (A,) = self.classes("A")
sess = Session()
q = sess.query(A).filter(A.id == 3)
@@ -3397,7 +3397,7 @@ class DiscriminatorOrPkNoneTest(fixtures.DeclarativeMappedTest):
)
def test_pk_not_null_discriminator_null_from_sub(self):
- B, = self.classes("B")
+ (B,) = self.classes("B")
sess = Session()
q = sess.query(B).filter(B.id == 4)
diff --git a/test/orm/test_bulk.py b/test/orm/test_bulk.py
index 7d591e906..79de19f68 100644
--- a/test/orm/test_bulk.py
+++ b/test/orm/test_bulk.py
@@ -81,7 +81,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest):
mapper(Order, o)
def test_bulk_save_return_defaults(self):
- User, = self.classes("User")
+ (User,) = self.classes("User")
s = Session()
objects = [User(name="u1"), User(name="u2"), User(name="u3")]
@@ -104,7 +104,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest):
eq_(objects[0].__dict__["id"], 1)
def test_bulk_save_mappings_preserve_order(self):
- User, = self.classes("User")
+ (User,) = self.classes("User")
s = Session()
@@ -160,7 +160,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest):
)
def test_bulk_save_no_defaults(self):
- User, = self.classes("User")
+ (User,) = self.classes("User")
s = Session()
objects = [User(name="u1"), User(name="u2"), User(name="u3")]
@@ -178,7 +178,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest):
assert "id" not in objects[0].__dict__
def test_bulk_save_updated_include_unchanged(self):
- User, = self.classes("User")
+ (User,) = self.classes("User")
s = Session(expire_on_commit=False)
objects = [User(name="u1"), User(name="u2"), User(name="u3")]
@@ -204,7 +204,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest):
)
def test_bulk_update(self):
- User, = self.classes("User")
+ (User,) = self.classes("User")
s = Session(expire_on_commit=False)
objects = [User(name="u1"), User(name="u2"), User(name="u3")]
@@ -234,7 +234,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest):
)
def test_bulk_insert(self):
- User, = self.classes("User")
+ (User,) = self.classes("User")
s = Session()
with self.sql_execution_asserter() as asserter:
@@ -259,7 +259,7 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest):
)
def test_bulk_insert_render_nulls(self):
- Order, = self.classes("Order")
+ (Order,) = self.classes("Order")
s = Session()
with self.sql_execution_asserter() as asserter:
diff --git a/test/orm/test_cycles.py b/test/orm/test_cycles.py
index 8cf4e4b5c..7dd349a74 100644
--- a/test/orm/test_cycles.py
+++ b/test/orm/test_cycles.py
@@ -1760,7 +1760,7 @@ class PostUpdateOnUpdateTest(fixtures.DeclarativeMappedTest):
def test_update_defaults_refresh_flush_event_no_postupdate(self):
# run the same test as test_update_defaults_refresh_flush_event
# but don't actually use any postupdate functionality
- A, = self.classes("A")
+ (A,) = self.classes("A")
canary = mock.Mock()
event.listen(A, "refresh_flush", canary.refresh_flush)
@@ -1845,7 +1845,7 @@ class PostUpdateOnUpdateTest(fixtures.DeclarativeMappedTest):
# run the same test as
# test_update_defaults_dont_expire_on_delete_no_postupdate
# but don't actually use any postupdate functionality
- A, = self.classes("A")
+ (A,) = self.classes("A")
canary = mock.Mock()
event.listen(A, "refresh_flush", canary.refresh_flush)
diff --git a/test/orm/test_lazy_relations.py b/test/orm/test_lazy_relations.py
index 0ababc262..ca7a58024 100644
--- a/test/orm/test_lazy_relations.py
+++ b/test/orm/test_lazy_relations.py
@@ -1417,7 +1417,7 @@ class O2MWOSideFixedTest(fixtures.MappedTest):
self._fixture(False)
City = self.classes.City
sess = Session(testing.db)
- c2, = sess.query(City).order_by(City.id).all()
+ (c2,) = sess.query(City).order_by(City.id).all()
eq_([p.id for p in c2.people], [])
diff --git a/test/orm/test_naturalpks.py b/test/orm/test_naturalpks.py
index e9b9ac44f..d7a4b0fab 100644
--- a/test/orm/test_naturalpks.py
+++ b/test/orm/test_naturalpks.py
@@ -1612,7 +1612,7 @@ class JoinedInheritanceTest(fixtures.MappedTest):
self._test_fk_threelevel(False)
def _test_pk(self, passive_updates):
- Engineer, = self.classes("Engineer")
+ (Engineer,) = self.classes("Engineer")
self._mapping_fixture(False, passive_updates)
sess = sa.orm.sessionmaker()()
@@ -1685,7 +1685,7 @@ class JoinedInheritanceTest(fixtures.MappedTest):
)
def _test_pk_threelevel(self, passive_updates):
- Owner, = self.classes("Owner")
+ (Owner,) = self.classes("Owner")
self._mapping_fixture(True, passive_updates)
diff --git a/test/orm/test_rel_fn.py b/test/orm/test_rel_fn.py
index 259d5ea9c..39f75b4e2 100644
--- a/test/orm/test_rel_fn.py
+++ b/test/orm/test_rel_fn.py
@@ -807,7 +807,7 @@ class ColumnCollectionsTest(
)
def test_determine_local_remote_pairs_o2m_composite_selfref_func_warning(
- self
+ self,
):
self._assert_non_simple_warning(
self._join_fixture_o2m_composite_selfref_func
@@ -823,7 +823,7 @@ class ColumnCollectionsTest(
)
def test_determine_local_remote_pairs_o2m_composite_selfref_func_annotated(
- self
+ self,
):
joincond = self._join_fixture_o2m_composite_selfref_func_annotated()
eq_(
diff --git a/test/orm/test_selectin_relations.py b/test/orm/test_selectin_relations.py
index 9ff60d925..4eecc4be6 100644
--- a/test/orm/test_selectin_relations.py
+++ b/test/orm/test_selectin_relations.py
@@ -3021,7 +3021,7 @@ class SingleInhSubclassTest(
s.commit()
def test_load(self):
- EmployerUser, = self.classes("EmployerUser")
+ (EmployerUser,) = self.classes("EmployerUser")
s = Session()
q = s.query(EmployerUser)