diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index eecb84c21b..87dd006115 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,16 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/django_spanner/schema.py b/django_spanner/schema.py index 2ef4ea7d24..a1dcf05a71 100644 --- a/django_spanner/schema.py +++ b/django_spanner/schema.py @@ -401,7 +401,9 @@ def add_index(self, model, index): "index": "|".join(index.fields), } with trace_call( - "CloudSpannerDjango.add_index", self.connection, trace_attributes, + "CloudSpannerDjango.add_index", + self.connection, + trace_attributes, ): super().add_index(model, index) diff --git a/docs/conf.py b/docs/conf.py index a176401457..bb5ce2db7d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -76,9 +76,9 @@ master_doc = "index" # General information about the project. -project = u"google-cloud-spanner-django" -copyright = u"2020, Google" -author = u"Google APIs" +project = "google-cloud-spanner-django" +copyright = "2020, Google" +author = "Google APIs" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -278,7 +278,7 @@ ( master_doc, "django-google-spanner.tex", - u"Spanner Django Documentation", + "Spanner Django Documentation", author, "manual", ) @@ -313,7 +313,7 @@ ( master_doc, "django-google-spanner", - u"django-google-spanner Documentation", + "django-google-spanner Documentation", [author], 1, ) @@ -332,7 +332,7 @@ ( master_doc, "django-google-spanner", - u"django-google-spanner Documentation", + "django-google-spanner Documentation", author, "django-google-spanner", "django-google-spanner Library", diff --git a/noxfile.py b/noxfile.py index 8871f89262..0cc5d6e77d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -15,7 +15,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = [ "docs", "django_spanner", diff --git a/tests/performance/django_spanner/test_benchmark.py b/tests/performance/django_spanner/test_benchmark.py index 31dd8f2987..e6540fd138 100644 --- a/tests/performance/django_spanner/test_benchmark.py +++ b/tests/performance/django_spanner/test_benchmark.py @@ -87,7 +87,10 @@ def __init__(self): @measure_execution_time def insert_one_row_with_fetch_after(self): author_kent = Author( - id=2, first_name="Pete", last_name="Allison", rating="2.1", + id=2, + first_name="Pete", + last_name="Allison", + rating="2.1", ) author_kent.save() last_name = Author.objects.get(pk=author_kent.id).last_name diff --git a/tests/system/django_spanner/test_decimal.py b/tests/system/django_spanner/test_decimal.py index 4155599af1..fd3469a135 100644 --- a/tests/system/django_spanner/test_decimal.py +++ b/tests/system/django_spanner/test_decimal.py @@ -53,12 +53,16 @@ def test_insert_and_search_decimal_value(self): Tests model object creation with Author model. """ author_kent = Author( - first_name="Arthur", last_name="Kent", rating=Decimal("4.1"), + first_name="Arthur", + last_name="Kent", + rating=Decimal("4.1"), ) author_kent.save() qs1 = Author.objects.filter(rating__gte=3).values("rating") self.assertValuesEqual( - qs1, [Decimal("4.1")], self.rating_transform, + qs1, + [Decimal("4.1")], + self.rating_transform, ) # Delete data from Author table. Author.objects.all().delete() @@ -94,7 +98,9 @@ def test_decimal_update(self): Tests decimal object update. """ author_kent = Author( - first_name="Arthur", last_name="Kent", rating=Decimal("4.1"), + first_name="Arthur", + last_name="Kent", + rating=Decimal("4.1"), ) author_kent.save() author_kent.rating = Decimal("4.2") @@ -103,7 +109,9 @@ def test_decimal_update(self): "rating" ) self.assertValuesEqual( - qs1, [Decimal("4.2")], self.rating_transform, + qs1, + [Decimal("4.2")], + self.rating_transform, ) # Delete data from Author table. Author.objects.all().delete() diff --git a/tests/system/django_spanner/test_queries.py b/tests/system/django_spanner/test_queries.py index 4d9218b309..4e6251cf2c 100644 --- a/tests/system/django_spanner/test_queries.py +++ b/tests/system/django_spanner/test_queries.py @@ -39,7 +39,9 @@ def test_insert_and_fetch_value(self): Inserting data into the model and retrieving it. """ author_kent = Author( - first_name="Arthur", last_name="Kent", rating=Decimal("4.1"), + first_name="Arthur", + last_name="Kent", + rating=Decimal("4.1"), ) author_kent.save() qs1 = Author.objects.all().values("first_name", "last_name") diff --git a/tests/unit/django_spanner/test_functions.py b/tests/unit/django_spanner/test_functions.py index 3624aac1c5..7b66f965b2 100644 --- a/tests/unit/django_spanner/test_functions.py +++ b/tests/unit/django_spanner/test_functions.py @@ -81,7 +81,9 @@ def test_cot(self): """ Tests cot function on a column. """ - q1 = Author.objects.values("num").annotate(num_cot=Cot("num"),) + q1 = Author.objects.values("num").annotate( + num_cot=Cot("num"), + ) compiler = SQLCompiler(q1.query, self.connection, "default") sql_query, params = compiler.query.as_sql(compiler, self.connection) self.assertEqual( @@ -95,7 +97,9 @@ def test_degrees(self): """ Tests degrees function on a column. """ - q1 = Author.objects.values("num").annotate(num_degrees=Degrees("num"),) + q1 = Author.objects.values("num").annotate( + num_degrees=Degrees("num"), + ) compiler = SQLCompiler(q1.query, self.connection, "default") sql_query, params = compiler.query.as_sql(compiler, self.connection) self.assertEqual( @@ -188,7 +192,8 @@ def test_pi(self): + "= (3.141592653589793)" ) self.assertEqual( - sql_query, expected_sql, + sql_query, + expected_sql, ) self.assertEqual(params, ()) diff --git a/tests/unit/django_spanner/test_introspection.py b/tests/unit/django_spanner/test_introspection.py index b50cbc032b..afb5147046 100644 --- a/tests/unit/django_spanner/test_introspection.py +++ b/tests/unit/django_spanner/test_introspection.py @@ -157,7 +157,8 @@ def run_sql_in_snapshot(*args, **kwargs): cursor=cursor, table_name="Table_1" ) self.assertEqual( - primary_key, "PK_column", + primary_key, + "PK_column", ) def test_get_primary_key_column_returns_none(self): @@ -174,7 +175,9 @@ def run_sql_in_snapshot(*args, **kwargs): primary_key = db_introspection.get_primary_key_column( cursor=cursor, table_name="Table_1" ) - self.assertIsNone(primary_key,) + self.assertIsNone( + primary_key, + ) def test_get_constraints(self): """ diff --git a/tests/unit/django_spanner/test_operations.py b/tests/unit/django_spanner/test_operations.py index a946b51303..ed52e1b49b 100644 --- a/tests/unit/django_spanner/test_operations.py +++ b/tests/unit/django_spanner/test_operations.py @@ -43,12 +43,14 @@ def test_sql_flush(self): def test_sql_flush_empty_table_list(self): self.assertEqual( - self.db_operations.sql_flush(style=no_style(), tables=[]), [], + self.db_operations.sql_flush(style=no_style(), tables=[]), + [], ) def test_adapt_datefield_value(self): self.assertIsInstance( - self.db_operations.adapt_datefield_value("dummy_date"), DateStr, + self.db_operations.adapt_datefield_value("dummy_date"), + DateStr, ) def test_adapt_datefield_value_none(self): @@ -204,7 +206,8 @@ def test_combine_expression_bit_extention(self): def test_combine_expression_multiply(self): self.assertEqual( - self.db_operations.combine_expression("*", ["10", "2"]), "10 * 2", + self.db_operations.combine_expression("*", ["10", "2"]), + "10 * 2", ) def test_combine_duration_expression_add(self): @@ -235,10 +238,16 @@ def test_combine_duration_expression_database_error(self): def test_lookup_cast_match_lookup_type(self): self.assertEqual( - self.db_operations.lookup_cast("contains",), "CAST(%s AS STRING)", + self.db_operations.lookup_cast( + "contains", + ), + "CAST(%s AS STRING)", ) def test_lookup_cast_unmatched_lookup_type(self): self.assertEqual( - self.db_operations.lookup_cast("dummy",), "%s", + self.db_operations.lookup_cast( + "dummy", + ), + "%s", ) diff --git a/tests/unit/django_spanner/test_schema.py b/tests/unit/django_spanner/test_schema.py index 570bcc572a..05bacebe70 100644 --- a/tests/unit/django_spanner/test_schema.py +++ b/tests/unit/django_spanner/test_schema.py @@ -129,7 +129,10 @@ def constraint_names(*args, **kwargs): ) self.assertSpanAttributes( "CloudSpannerDjango.delete_model", - attributes=dict(BASE_ATTRIBUTES, model_name="tests_author",), + attributes=dict( + BASE_ATTRIBUTES, + model_name="tests_author", + ), span=span_list[1], ) @@ -168,7 +171,9 @@ def test_remove_field(self): self.assertSpanAttributes( "CloudSpannerDjango.remove_field", attributes=dict( - BASE_ATTRIBUTES, model_name="tests_author", field="num", + BASE_ATTRIBUTES, + model_name="tests_author", + field="num", ), span=span_list[0], ) @@ -216,7 +221,9 @@ def constraint_names(*args, **kwargs): self.assertSpanAttributes( "CloudSpannerDjango.remove_field", attributes=dict( - BASE_ATTRIBUTES, model_name="tests_author", field="num", + BASE_ATTRIBUTES, + model_name="tests_author", + field="num", ), span=span_list[1], ) @@ -266,7 +273,9 @@ def test_column_add_index(self): self.assertSpanAttributes( "CloudSpannerDjango.add_index", attributes=dict( - BASE_ATTRIBUTES, model_name="tests_author", index="num", + BASE_ATTRIBUTES, + model_name="tests_author", + index="num", ), span=span_list[0], )