Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 0d8d6dc

Browse files
authored
refactor: update black version to fix lint CI (#130)
1 parent 6b4ad09 commit 0d8d6dc

File tree

12 files changed

+154
-43
lines changed

12 files changed

+154
-43
lines changed

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- sqlalchemy=1.3.23
1111

1212
# dev
13-
- black=19.10b0 # Same as ibis
13+
- black=22.3.0 # Same as ibis
1414
- pytest
1515
- pytest-cov
1616
- pytest-mock

ibis_bigquery/udf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def validate_output_type(*args):
2323

2424
__all__ = ("udf",)
2525

26-
_udf_name_cache: Dict[str, Iterable[int]] = (collections.defaultdict(itertools.count))
26+
_udf_name_cache: Dict[str, Iterable[int]] = collections.defaultdict(itertools.count)
2727

2828

2929
def create_udf_node(name, fields):

ibis_bigquery/udf/core.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ def wrapper(*args, **kwargs):
7070
def rewrite_print(node):
7171
return ast.Call(
7272
func=ast.Attribute(
73-
value=ast.Name(id="console", ctx=ast.Load()), attr="log", ctx=ast.Load(),
73+
value=ast.Name(id="console", ctx=ast.Load()),
74+
attr="log",
75+
ctx=ast.Load(),
7476
),
7577
args=node.args,
7678
keywords=node.keywords,
@@ -395,7 +397,9 @@ def visit_Compare(self, node):
395397
@semicolon
396398
def visit_AugAssign(self, node):
397399
return "{} {}= {}".format(
398-
self.visit(node.target), self.visit(node.op), self.visit(node.value),
400+
self.visit(node.target),
401+
self.visit(node.op),
402+
self.visit(node.value),
399403
)
400404

401405
def visit_Module(self, node):
@@ -420,8 +424,7 @@ def visit_Lambda(self, node):
420424

421425
@contextlib.contextmanager
422426
def local_scope(self):
423-
"""Assign symbols to local variables.
424-
"""
427+
"""Assign symbols to local variables."""
425428
self.scope = self.scope.new_child()
426429
try:
427430
yield self.scope
@@ -444,7 +447,9 @@ def visit_If(self, node):
444447

445448
def visit_IfExp(self, node):
446449
return "({} ? {} : {})".format(
447-
self.visit(node.test), self.visit(node.body), self.visit(node.orelse),
450+
self.visit(node.test),
451+
self.visit(node.body),
452+
self.visit(node.orelse),
448453
)
449454

450455
def visit_Index(self, node):
@@ -604,6 +609,6 @@ def range(n):
604609
z = (x if y else b) + 2 + foobar
605610
foo = Rectangle(1, 2)
606611
nnn = len(values)
607-
return [sum(values) - a + b * y ** -x, z, foo.width, nnn]
612+
return [sum(values) - a + b * y**-x, z, foo.width, nnn]
608613

609614
print(my_func.js)

ibis_bigquery/udf/find.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55

66
class NameFinder:
7-
"""Helper class to find the unique names in an AST.
8-
"""
7+
"""Helper class to find the unique names in an AST."""
98

109
__slots__ = ()
1110

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ google-cloud-bigquery
55
pydata-google-auth
66

77
# dev
8-
black==19.10b0
8+
black==22.3.0
99
pytest
1010
pytest-cov
1111
pytest-mock

tests/system/conftest.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,18 @@ def credentials(default_credentials):
7272
@pytest.fixture(scope="session")
7373
def client(credentials, project_id):
7474
return bq.connect(
75-
project_id=project_id, dataset_id=DATASET_ID, credentials=credentials,
75+
project_id=project_id,
76+
dataset_id=DATASET_ID,
77+
credentials=credentials,
7678
)
7779

7880

7981
@pytest.fixture(scope="session")
8082
def client2(credentials, project_id):
8183
return bq.connect(
82-
project_id=project_id, dataset_id=DATASET_ID, credentials=credentials,
84+
project_id=project_id,
85+
dataset_id=DATASET_ID,
86+
credentials=credentials,
8387
)
8488

8589

@@ -184,7 +188,9 @@ def load_functional_alltypes_data(request, bqclient, create_functional_alltypes_
184188
filepath = download_file("{}/functional_alltypes.csv".format(TESTING_DATA_URI))
185189
with open(filepath.name, "rb") as csvfile:
186190
job = bqclient.load_table_from_file(
187-
csvfile, table, job_config=load_config,
191+
csvfile,
192+
table,
193+
job_config=load_config,
188194
).result()
189195
if job.error_result:
190196
print("error")
@@ -238,7 +244,9 @@ def load_functional_alltypes_parted_data(
238244
filepath = download_file("{}/functional_alltypes.csv".format(TESTING_DATA_URI))
239245
with open(filepath.name, "rb") as csvfile:
240246
job = bqclient.load_table_from_file(
241-
csvfile, table, job_config=load_config,
247+
csvfile,
248+
table,
249+
job_config=load_config,
242250
).result()
243251
if job.error_result:
244252
print("error")
@@ -261,7 +269,9 @@ def load_struct_table_data(request, bqclient, struct_bq_table):
261269
filepath = download_file("{}/struct_table.avro".format(TESTING_DATA_URI))
262270
with open(filepath.name, "rb") as avrofile:
263271
job = bqclient.load_table_from_file(
264-
avrofile, struct_bq_table, job_config=load_config,
272+
avrofile,
273+
struct_bq_table,
274+
job_config=load_config,
265275
).result()
266276
if job.error_result:
267277
print("error")

tests/system/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,8 @@ def test_string_to_timestamp(client):
615615
assert result == timestamp
616616

617617
timestamp_tz = pd.Timestamp(
618-
datetime.datetime(year=2017, month=2, day=6, hour=5), tz=pytz.timezone("UTC"),
618+
datetime.datetime(year=2017, month=2, day=6, hour=5),
619+
tz=pytz.timezone("UTC"),
619620
)
620621
expr_tz = ibis.literal("2017-02-06").to_timestamp("%F", "America/New_York")
621622
result_tz = client.execute(expr_tz)

tests/system/test_connect.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ def mock_credentials(*args, **kwargs):
2727
return creds, "default-project-id"
2828

2929
monkeypatch.setattr(pydata_google_auth, "default", mock_credentials)
30-
con = ibis_bigquery.connect(project_id="explicit-project-id",)
30+
con = ibis_bigquery.connect(
31+
project_id="explicit-project-id",
32+
)
3133
assert con.billing_project == "explicit-project-id"
3234

3335

3436
def test_without_dataset(project_id, credentials):
35-
con = ibis_bigquery.connect(project_id=project_id, credentials=credentials,)
37+
con = ibis_bigquery.connect(
38+
project_id=project_id,
39+
credentials=credentials,
40+
)
3641
with pytest.raises(ValueError, match="Unable to determine BigQuery"):
3742
con.list_tables()
3843

@@ -62,7 +67,8 @@ def mock_default(*args, **kwargs):
6267
monkeypatch.setattr(pydata_google_auth, "default", mock_default)
6368

6469
ibis_bigquery.connect(
65-
project_id=project_id, dataset_id="bigquery-public-data.stackoverflow",
70+
project_id=project_id,
71+
dataset_id="bigquery-public-data.stackoverflow",
6672
)
6773

6874
assert len(mock_calls) == 1
@@ -73,7 +79,10 @@ def mock_default(*args, **kwargs):
7379
auth_local_webserver = kwargs["use_local_webserver"]
7480
auth_cache = kwargs["credentials_cache"]
7581
assert not auth_local_webserver
76-
assert isinstance(auth_cache, pydata_google_auth.cache.ReadWriteCredentialsCache,)
82+
assert isinstance(
83+
auth_cache,
84+
pydata_google_auth.cache.ReadWriteCredentialsCache,
85+
)
7786

7887

7988
def test_auth_local_webserver(project_id, credentials, monkeypatch):
@@ -137,7 +146,10 @@ def mock_default(*args, **kwargs):
137146
assert len(mock_calls) == 1
138147
_, kwargs = mock_calls[0]
139148
auth_cache = kwargs["credentials_cache"]
140-
assert isinstance(auth_cache, pydata_google_auth.cache.WriteOnlyCredentialsCache,)
149+
assert isinstance(
150+
auth_cache,
151+
pydata_google_auth.cache.WriteOnlyCredentialsCache,
152+
)
141153

142154

143155
def test_auth_cache_none(project_id, credentials, monkeypatch):

tests/system/udf/test_udf_execute.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def my_add(a, b):
3939

4040
expected = (df.double_col + df.double_col).rename("tmp")
4141
tm.assert_series_equal(
42-
result.value_counts().sort_index(), expected.value_counts().sort_index(),
42+
result.value_counts().sort_index(),
43+
expected.value_counts().sort_index(),
4344
)
4445

4546

@@ -216,11 +217,15 @@ def my_len(s):
216217
param(dt.float64, dt.int64, marks=pytest.mark.xfail(raises=TypeError)),
217218
# complex argument type, valid return type
218219
param(
219-
dt.Array(dt.int64), dt.float64, marks=pytest.mark.xfail(raises=TypeError),
220+
dt.Array(dt.int64),
221+
dt.float64,
222+
marks=pytest.mark.xfail(raises=TypeError),
220223
),
221224
# valid argument type, complex invalid return type
222225
param(
223-
dt.float64, dt.Array(dt.int64), marks=pytest.mark.xfail(raises=TypeError),
226+
dt.float64,
227+
dt.Array(dt.int64),
228+
marks=pytest.mark.xfail(raises=TypeError),
224229
),
225230
# both invalid
226231
param(

tests/unit/test_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
["project", "dataset", "expected"],
99
[
1010
("my-project", "", ("my-project", "my-project", "")),
11-
("my-project", "my_dataset", ("my-project", "my-project", "my_dataset"),),
11+
(
12+
"my-project",
13+
"my_dataset",
14+
("my-project", "my-project", "my_dataset"),
15+
),
1216
(
1317
"billing-project",
1418
"data-project.my_dataset",

0 commit comments

Comments
 (0)