Skip to content

Commit 2b1f5c4

Browse files
chore(python): use black==22.3.0 (#438)
Source-Link: googleapis/synthtool@6fab84a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe
1 parent fd1dada commit 2b1f5c4

21 files changed

+186
-77
lines changed

.github/.OwlBot.lock.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae
16+
digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe

docs/conf.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,13 @@
314314
# One entry per manual page. List of tuples
315315
# (source start file, name, description, authors, manual section).
316316
man_pages = [
317-
(root_doc, "sqlalchemy-bigquery", "sqlalchemy-bigquery Documentation", [author], 1,)
317+
(
318+
root_doc,
319+
"sqlalchemy-bigquery",
320+
"sqlalchemy-bigquery Documentation",
321+
[author],
322+
1,
323+
)
318324
]
319325

320326
# If true, show URL addresses after external links.
@@ -355,7 +361,10 @@
355361
intersphinx_mapping = {
356362
"python": ("https://python.readthedocs.org/en/latest/", None),
357363
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
358-
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
364+
"google.api_core": (
365+
"https://googleapis.dev/python/google-api-core/latest/",
366+
None,
367+
),
359368
"grpc": ("https://grpc.github.io/grpc/python/", None),
360369
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
361370
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),

noxfile.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import nox
2626

2727

28-
BLACK_VERSION = "black==19.10b0"
28+
BLACK_VERSION = "black==22.3.0"
2929
BLACK_PATHS = ["docs", "sqlalchemy_bigquery", "tests", "noxfile.py", "setup.py"]
3030

3131
DEFAULT_PYTHON_VERSION = "3.8"
@@ -61,7 +61,9 @@ def lint(session):
6161
"""
6262
session.install("flake8", BLACK_VERSION)
6363
session.run(
64-
"black", "--check", *BLACK_PATHS,
64+
"black",
65+
"--check",
66+
*BLACK_PATHS,
6567
)
6668
session.run("flake8", "sqlalchemy_bigquery", "tests")
6769

@@ -71,7 +73,8 @@ def blacken(session):
7173
"""Run black. Format code to uniform standard."""
7274
session.install(BLACK_VERSION)
7375
session.run(
74-
"black", *BLACK_PATHS,
76+
"black",
77+
*BLACK_PATHS,
7578
)
7679

7780

samples/snippets/noxfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# WARNING - WARNING - WARNING - WARNING - WARNING
3030
# WARNING - WARNING - WARNING - WARNING - WARNING
3131

32-
BLACK_VERSION = "black==19.10b0"
32+
BLACK_VERSION = "black==22.3.0"
3333

3434
# Copy `noxfile_config.py` to your directory and modify it instead.
3535

@@ -253,7 +253,7 @@ def py(session: nox.sessions.Session) -> None:
253253

254254

255255
def _get_repo_root() -> Optional[str]:
256-
""" Returns the root folder of the project. """
256+
"""Returns the root folder of the project."""
257257
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
258258
p = Path(os.getcwd())
259259
for i in range(10):

sqlalchemy_bigquery/_struct.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ def _field_index(self, name, operator):
124124
bindparam_type=sqlalchemy.types.String(),
125125
)
126126

127-
128127
else:
129128

130129
def _field_index(self, name, operator):
131130
return sqlalchemy.sql.default_comparator._check_literal(
132-
self.expr, operator, name, bindparam_type=sqlalchemy.types.String(),
131+
self.expr,
132+
operator,
133+
name,
134+
bindparam_type=sqlalchemy.types.String(),
133135
)
134136

135137

sqlalchemy_bigquery/base.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class BigQueryIdentifierPreparer(IdentifierPreparer):
7676

7777
def __init__(self, dialect):
7878
super(BigQueryIdentifierPreparer, self).__init__(
79-
dialect, initial_quote="`",
79+
dialect,
80+
initial_quote="`",
8081
)
8182

8283
def quote_column(self, value):
@@ -349,7 +350,7 @@ def group_by_clause(self, select, **kw):
349350
__expanding_conflict = "" if __sqlalchemy_version_info < (1, 4, 27) else "__"
350351

351352
__in_expanding_bind = _helpers.substitute_string_re_method(
352-
fr"""
353+
rf"""
353354
\sIN\s\( # ' IN ('
354355
(
355356
{__expanding_conflict}\[ # Expanding placeholder
@@ -435,7 +436,7 @@ def visit_notendswith_op_binary(self, binary, operator, **kw):
435436
__placeholder = re.compile(r"%\(([^\]:]+)(:[^\]:]+)?\)s$").match
436437

437438
__expanded_param = re.compile(
438-
fr"\({__expanding_conflict}\[" fr"{__expanding_text}" fr"_[^\]]+\]\)$"
439+
rf"\({__expanding_conflict}\[" rf"{__expanding_text}" rf"_[^\]]+\]\)$"
439440
).match
440441

441442
__remove_type_parameter = _helpers.substitute_string_re_method(
@@ -681,8 +682,7 @@ def literal_processor(self, dialect):
681682

682683

683684
class BQClassTaggedStr(sqlalchemy.sql.type_api.TypeEngine):
684-
"""Type that can get literals via str
685-
"""
685+
"""Type that can get literals via str"""
686686

687687
@staticmethod
688688
def process_literal_as_class_tagged_str(value):
@@ -693,8 +693,7 @@ def literal_processor(self, dialect):
693693

694694

695695
class BQTimestamp(sqlalchemy.sql.type_api.TypeEngine):
696-
"""Type that can get literals via str
697-
"""
696+
"""Type that can get literals via str"""
698697

699698
@staticmethod
700699
def process_timestamp_literal(value):

sqlalchemy_bigquery/geography.py

+71-18
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ class Lake(Base):
100100

101101
def __init__(self):
102102
super().__init__(
103-
geometry_type=None, spatial_index=False, srid=SRID,
103+
geometry_type=None,
104+
spatial_index=False,
105+
srid=SRID,
104106
)
105107
self.extended = True
106108

@@ -198,43 +200,94 @@ def _fixup_st_arguments(element, compiler, **kw):
198200
st_boundary=(GEOGRAPHY,),
199201
st_centroid=(GEOGRAPHY,),
200202
st_centroid_agg=(GEOGRAPHY,),
201-
st_closestpoint=(GEOGRAPHY, GEOGRAPHY,),
203+
st_closestpoint=(
204+
GEOGRAPHY,
205+
GEOGRAPHY,
206+
),
202207
st_clusterdbscan=(GEOGRAPHY,),
203-
st_contains=(GEOGRAPHY, GEOGRAPHY,),
208+
st_contains=(
209+
GEOGRAPHY,
210+
GEOGRAPHY,
211+
),
204212
st_convexhull=(GEOGRAPHY,),
205-
st_coveredby=(GEOGRAPHY, GEOGRAPHY,),
206-
st_covers=(GEOGRAPHY, GEOGRAPHY,),
207-
st_difference=(GEOGRAPHY, GEOGRAPHY,),
213+
st_coveredby=(
214+
GEOGRAPHY,
215+
GEOGRAPHY,
216+
),
217+
st_covers=(
218+
GEOGRAPHY,
219+
GEOGRAPHY,
220+
),
221+
st_difference=(
222+
GEOGRAPHY,
223+
GEOGRAPHY,
224+
),
208225
st_dimension=(GEOGRAPHY,),
209-
st_disjoint=(GEOGRAPHY, GEOGRAPHY,),
210-
st_distance=(GEOGRAPHY, GEOGRAPHY,),
226+
st_disjoint=(
227+
GEOGRAPHY,
228+
GEOGRAPHY,
229+
),
230+
st_distance=(
231+
GEOGRAPHY,
232+
GEOGRAPHY,
233+
),
211234
st_dump=(GEOGRAPHY,),
212-
st_dwithin=(GEOGRAPHY, GEOGRAPHY,),
235+
st_dwithin=(
236+
GEOGRAPHY,
237+
GEOGRAPHY,
238+
),
213239
st_endpoint=(GEOGRAPHY,),
214-
st_equals=(GEOGRAPHY, GEOGRAPHY,),
240+
st_equals=(
241+
GEOGRAPHY,
242+
GEOGRAPHY,
243+
),
215244
st_exteriorring=(GEOGRAPHY,),
216245
st_geohash=(GEOGRAPHY,),
217-
st_intersection=(GEOGRAPHY, GEOGRAPHY,),
218-
st_intersects=(GEOGRAPHY, GEOGRAPHY,),
246+
st_intersection=(
247+
GEOGRAPHY,
248+
GEOGRAPHY,
249+
),
250+
st_intersects=(
251+
GEOGRAPHY,
252+
GEOGRAPHY,
253+
),
219254
st_intersectsbox=(GEOGRAPHY,),
220255
st_iscollection=(GEOGRAPHY,),
221256
st_isempty=(GEOGRAPHY,),
222257
st_length=(GEOGRAPHY,),
223-
st_makeline=(GEOGRAPHY, GEOGRAPHY,),
224-
st_makepolygon=(GEOGRAPHY, GEOGRAPHY,),
258+
st_makeline=(
259+
GEOGRAPHY,
260+
GEOGRAPHY,
261+
),
262+
st_makepolygon=(
263+
GEOGRAPHY,
264+
GEOGRAPHY,
265+
),
225266
st_makepolygonoriented=(GEOGRAPHY,),
226-
st_maxdistance=(GEOGRAPHY, GEOGRAPHY,),
267+
st_maxdistance=(
268+
GEOGRAPHY,
269+
GEOGRAPHY,
270+
),
227271
st_npoints=(GEOGRAPHY,),
228272
st_numpoints=(GEOGRAPHY,),
229273
st_perimeter=(GEOGRAPHY,),
230274
st_pointn=(GEOGRAPHY,),
231275
st_simplify=(GEOGRAPHY,),
232276
st_snaptogrid=(GEOGRAPHY,),
233277
st_startpoint=(GEOGRAPHY,),
234-
st_touches=(GEOGRAPHY, GEOGRAPHY,),
235-
st_union=(GEOGRAPHY, GEOGRAPHY,),
278+
st_touches=(
279+
GEOGRAPHY,
280+
GEOGRAPHY,
281+
),
282+
st_union=(
283+
GEOGRAPHY,
284+
GEOGRAPHY,
285+
),
236286
st_union_agg=(GEOGRAPHY,),
237-
st_within=(GEOGRAPHY, GEOGRAPHY,),
287+
st_within=(
288+
GEOGRAPHY,
289+
GEOGRAPHY,
290+
),
238291
st_x=(GEOGRAPHY,),
239292
st_y=(GEOGRAPHY,),
240293
)

tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def literal(value):
6969
with mock.patch("sqlalchemy.testing.suite.test_types.literal", literal):
7070
super(TimestampMicrosecondsTest, self).test_literal()
7171

72-
7372
else:
7473
from sqlalchemy.testing.suite import (
7574
FetchLimitOffsetTest as _FetchLimitOffsetTest,
@@ -95,7 +94,9 @@ def test_limit_render_multiple_times(self, connection):
9594
u = sqlalchemy.union(select(stmt), select(stmt)).subquery().select()
9695

9796
self._assert_result(
98-
connection, u, [(1,)],
97+
connection,
98+
u,
99+
[(1,)],
99100
)
100101

101102
del DifficultParametersTest # exercises column names illegal in BQ
@@ -193,7 +194,10 @@ def test_select_exists(self, connection):
193194
eq_(
194195
connection.execute(
195196
select([stuff.c.id]).where(
196-
and_(stuff.c.id == 1, exists().where(stuff.c.data == "some data"),)
197+
and_(
198+
stuff.c.id == 1,
199+
exists().where(stuff.c.data == "some data"),
200+
)
197201
)
198202
).fetchall(),
199203
[(1,)],

tests/system/conftest.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def load_sample_data(
5353

5454
with open(DATA_DIR / filename, "rb") as data_file:
5555
return bigquery_client.load_table_from_file(
56-
data_file, full_table_id, job_config=sample_config,
56+
data_file,
57+
full_table_id,
58+
job_config=sample_config,
5759
)
5860

5961

@@ -86,7 +88,9 @@ def bigquery_dataset(
8688
filename="sample_one_row.json",
8789
)
8890
job2.result()
89-
view = bigquery.Table(f"{project_id}.{dataset_id}.sample_view",)
91+
view = bigquery.Table(
92+
f"{project_id}.{dataset_id}.sample_view",
93+
)
9094
view.view_query = f"SELECT string FROM `{dataset_id}.sample`"
9195
bigquery_client.create_table(view)
9296
yield dataset_id

tests/system/test__struct.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ def test_unnest_and_struct_access_233(engine, bigquery_dataset, metadata):
148148
metadata.create_all(engine)
149149

150150
conn.execute(
151-
mock_table.insert(), dict(mock_id="x"), dict(mock_id="y"), dict(mock_id="z"),
151+
mock_table.insert(),
152+
dict(mock_id="x"),
153+
dict(mock_id="y"),
154+
dict(mock_id="z"),
152155
)
153156
conn.execute(
154157
another_mock_table.insert(),
@@ -160,7 +163,8 @@ def test_unnest_and_struct_access_233(engine, bigquery_dataset, metadata):
160163
).subquery()
161164

162165
join = mock_table.join(
163-
subquery, subquery.c.another_mock_objects["object_id"] == mock_table.c.mock_id,
166+
subquery,
167+
subquery.c.another_mock_objects["object_id"] == mock_table.c.mock_id,
164168
)
165169

166170
query = select(mock_table).select_from(join)

tests/system/test_geography.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def test_geoalchemy2_core(bigquery_dataset):
5656

5757
conn.execute(
5858
lake_table.insert().values(
59-
name="Majeur", geog="POLYGON((0 0,1 0,1 1,0 1,0 0))",
59+
name="Majeur",
60+
geog="POLYGON((0 0,1 0,1 1,0 1,0 0))",
6061
)
6162
)
6263

@@ -113,7 +114,8 @@ def test_geoalchemy2_core(bigquery_dataset):
113114

114115
conn.execute(
115116
lake_table.insert().values(
116-
name="test2", geog=WKT("POLYGON((1 0,3 0,3 2,1 2,1 0))"),
117+
name="test2",
118+
geog=WKT("POLYGON((1 0,3 0,3 2,1 2,1 0))"),
117119
)
118120
)
119121
assert (

tests/system/test_helpers.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def test_create_bigquery_client_with_credentials_path_respects_project(
5454
https://github.com/googleapis/python-bigquery-sqlalchemy/issues/48
5555
"""
5656
bqclient = module_under_test.create_bigquery_client(
57-
credentials_path=credentials_path, project_id="connection-url-project",
57+
credentials_path=credentials_path,
58+
project_id="connection-url-project",
5859
)
5960
assert bqclient.project == "connection-url-project"
6061

@@ -76,7 +77,8 @@ def test_create_bigquery_client_with_credentials_info_respects_project(
7677
https://github.com/googleapis/python-bigquery-sqlalchemy/issues/48
7778
"""
7879
bqclient = module_under_test.create_bigquery_client(
79-
credentials_info=credentials_info, project_id="connection-url-project",
80+
credentials_info=credentials_info,
81+
project_id="connection-url-project",
8082
)
8183
assert bqclient.project == "connection-url-project"
8284

@@ -98,6 +100,7 @@ def test_create_bigquery_client_with_credentials_base64_respects_project(
98100
https://github.com/googleapis/python-bigquery-sqlalchemy/issues/48
99101
"""
100102
bqclient = module_under_test.create_bigquery_client(
101-
credentials_base64=credentials_base64, project_id="connection-url-project",
103+
credentials_base64=credentials_base64,
104+
project_id="connection-url-project",
102105
)
103106
assert bqclient.project == "connection-url-project"

0 commit comments

Comments
 (0)