Skip to content

Commit 403145a

Browse files
authored
chore: Upgrade black version and re-run it (#860)
1 parent 22c4340 commit 403145a

File tree

10 files changed

+60
-63
lines changed

10 files changed

+60
-63
lines changed

packages/google-cloud-ndb/google/cloud/ndb/_cache.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def global_set(key, value, expires=None, read=False):
306306

307307

308308
class _GlobalCacheSetBatch(_GlobalCacheBatch):
309-
"""Batch for global cache set requests. """
309+
"""Batch for global cache set requests."""
310310

311311
def __init__(self, options):
312312
self.expires = options.get("expires")
@@ -408,7 +408,7 @@ def global_set_if_not_exists(key, value, expires=None):
408408

409409

410410
class _GlobalCacheSetIfNotExistsBatch(_GlobalCacheSetBatch):
411-
"""Batch for global cache set_if_not_exists requests. """
411+
"""Batch for global cache set_if_not_exists requests."""
412412

413413
def add(self, key, value):
414414
"""Add a key, value pair to store in the cache.
@@ -507,7 +507,7 @@ def _global_watch(key, value):
507507

508508

509509
class _GlobalCacheWatchBatch(_GlobalCacheSetBatch):
510-
"""Batch for global cache watch requests. """
510+
"""Batch for global cache watch requests."""
511511

512512
def make_call(self):
513513
"""Call :method:`GlobalCache.watch`."""
@@ -537,7 +537,7 @@ def global_unwatch(key):
537537

538538

539539
class _GlobalCacheUnwatchBatch(_GlobalCacheDeleteBatch):
540-
"""Batch for global cache unwatch requests. """
540+
"""Batch for global cache unwatch requests."""
541541

542542
def make_call(self):
543543
"""Call :method:`GlobalCache.unwatch`."""
@@ -574,7 +574,7 @@ def _global_compare_and_swap(key, value, expires=None):
574574

575575

576576
class _GlobalCacheCompareAndSwapBatch(_GlobalCacheSetBatch):
577-
"""Batch for global cache compare and swap requests. """
577+
"""Batch for global cache compare and swap requests."""
578578

579579
def make_call(self):
580580
"""Call :method:`GlobalCache.compare_and_swap`."""

packages/google-cloud-ndb/google/cloud/ndb/_datastore_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,11 +767,11 @@ def __init__(self, result_type, result_pb, order_by=None):
767767
self.cursor = Cursor(result_pb.cursor)
768768

769769
def __lt__(self, other):
770-
"""For total ordering. """
770+
"""For total ordering."""
771771
return self._compare(other) == -1
772772

773773
def __eq__(self, other):
774-
"""For total ordering. """
774+
"""For total ordering."""
775775
if isinstance(other, _Result) and self.result_pb == other.result_pb:
776776
return True
777777

packages/google-cloud-ndb/google/cloud/ndb/_eventloop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ def add_idle(callback, *args, **kwargs):
361361

362362

363363
def call_soon(callback, *args, **kwargs):
364-
"""Calls :method:`EventLoop.call_soon` on current event loop. """
364+
"""Calls :method:`EventLoop.call_soon` on current event loop."""
365365
loop = get_event_loop()
366366
loop.call_soon(callback, *args, **kwargs)
367367

368368

369369
def queue_call(delay, callback, *args, **kwargs):
370-
"""Calls :method:`EventLoop.queue_call` on current event loop. """
370+
"""Calls :method:`EventLoop.queue_call` on current event loop."""
371371
loop = get_event_loop()
372372
loop.queue_call(delay, callback, *args, **kwargs)
373373

packages/google-cloud-ndb/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
MAJOR_INTERPRETERS = "3.8"
3131
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
3232

33-
BLACK_VERSION = "black==20.8b1"
33+
BLACK_VERSION = "black==22.3.0"
3434

3535

3636
def get_path(*names):

packages/google-cloud-ndb/tests/system/test_query.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,9 +1605,9 @@ class SomeKind(ndb.Model):
16051605
entity_id,
16061606
**{
16071607
"foo": 1,
1608-
"bar.one": [u"pish", u"bish"],
1609-
"bar.two": [u"posh", u"bosh"],
1610-
"bar.three": [u"pash", u"bash"],
1608+
"bar.one": ["pish", "bish"],
1609+
"bar.two": ["posh", "bosh"],
1610+
"bar.three": ["pash", "bash"],
16111611
}
16121612
)
16131613

@@ -1617,9 +1617,9 @@ class SomeKind(ndb.Model):
16171617
entity_id,
16181618
**{
16191619
"foo": 2,
1620-
"bar.one": [u"bish", u"pish"],
1621-
"bar.two": [u"bosh", u"posh"],
1622-
"bar.three": [u"bass", u"pass"],
1620+
"bar.one": ["bish", "pish"],
1621+
"bar.two": ["bosh", "posh"],
1622+
"bar.three": ["bass", "pass"],
16231623
}
16241624
)
16251625

@@ -1629,9 +1629,9 @@ class SomeKind(ndb.Model):
16291629
entity_id,
16301630
**{
16311631
"foo": 3,
1632-
"bar.one": [u"pish", u"bish"],
1633-
"bar.two": [u"fosh", u"posh"],
1634-
"bar.three": [u"fash", u"bash"],
1632+
"bar.one": ["pish", "bish"],
1633+
"bar.two": ["fosh", "posh"],
1634+
"bar.three": ["fash", "bash"],
16351635
}
16361636
)
16371637

@@ -1640,8 +1640,8 @@ class SomeKind(ndb.Model):
16401640
query = (
16411641
SomeKind.query()
16421642
.filter(
1643-
SomeKind.bar == OtherKind(one=u"pish", two=u"posh"),
1644-
SomeKind.bar == OtherKind(two=u"posh", three=u"pash"),
1643+
SomeKind.bar == OtherKind(one="pish", two="posh"),
1644+
SomeKind.bar == OtherKind(two="posh", three="pash"),
16451645
)
16461646
.order(SomeKind.foo)
16471647
)
@@ -1668,9 +1668,9 @@ class SomeKind(ndb.Model):
16681668
entity_id,
16691669
**{
16701670
"foo": 1,
1671-
"b.one": [u"pish", u"bish"],
1672-
"b.two": [u"posh", u"bosh"],
1673-
"b.three": [u"pash", u"bash"],
1671+
"b.one": ["pish", "bish"],
1672+
"b.two": ["posh", "bosh"],
1673+
"b.three": ["pash", "bash"],
16741674
}
16751675
)
16761676

@@ -1680,7 +1680,7 @@ class SomeKind(ndb.Model):
16801680

16811681
results = query.fetch()
16821682
assert len(results) == 1
1683-
assert results[0].bar[0].one == u"pish"
1683+
assert results[0].bar[0].one == "pish"
16841684

16851685

16861686
@pytest.mark.usefixtures("client_context")

packages/google-cloud-ndb/tests/unit/test__datastore_query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_make_filter():
3939
op=query_pb2.PropertyFilter.Operator.EQUAL,
4040
value=entity_pb2.Value(string_value="Harold"),
4141
)
42-
assert _datastore_query.make_filter("harry", "=", u"Harold") == expected
42+
assert _datastore_query.make_filter("harry", "=", "Harold") == expected
4343

4444

4545
def test_make_composite_and_filter():
@@ -873,11 +873,11 @@ class Test_PostFilterQueryIteratorImpl:
873873
@staticmethod
874874
def test_constructor():
875875
foo = model.StringProperty("foo")
876-
query = query_module.QueryOptions(offset=20, limit=10, filters=foo == u"this")
876+
query = query_module.QueryOptions(offset=20, limit=10, filters=foo == "this")
877877
predicate = object()
878878
iterator = _datastore_query._PostFilterQueryIteratorImpl(query, predicate)
879879
assert iterator._result_set._query == query_module.QueryOptions(
880-
filters=foo == u"this"
880+
filters=foo == "this"
881881
)
882882
assert iterator._offset == 20
883883
assert iterator._limit == 10
@@ -1030,11 +1030,11 @@ def test_cursor_after_no_cursor():
10301030
@staticmethod
10311031
def test__more_results_after_limit():
10321032
foo = model.StringProperty("foo")
1033-
query = query_module.QueryOptions(offset=20, limit=10, filters=foo == u"this")
1033+
query = query_module.QueryOptions(offset=20, limit=10, filters=foo == "this")
10341034
predicate = object()
10351035
iterator = _datastore_query._PostFilterQueryIteratorImpl(query, predicate)
10361036
assert iterator._result_set._query == query_module.QueryOptions(
1037-
filters=foo == u"this"
1037+
filters=foo == "this"
10381038
)
10391039
assert iterator._offset == 20
10401040
assert iterator._limit == 10

packages/google-cloud-ndb/tests/unit/test__legacy_entity_pb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_TryMerge_mutable_key_path_not_bytes():
9999
assert element.has_type()
100100
assert element.type == "D"
101101
# Not quite sure how this type could be set from a decoder string
102-
element.set_type(u"E")
102+
element.set_type("E")
103103
assert element.type == "E"
104104

105105
@staticmethod

packages/google-cloud-ndb/tests/unit/test_key.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def test_constructor_with_unicode():
5252
5353
https://github.com/googleapis/python-ndb/issues/322
5454
"""
55-
key = key_module.Key(u"Kind", 42)
55+
key = key_module.Key("Kind", 42)
5656

57-
assert key._key == google.cloud.datastore.Key(u"Kind", 42, project="testing")
57+
assert key._key == google.cloud.datastore.Key("Kind", 42, project="testing")
5858
assert key._reference is None
5959

6060
@staticmethod
@@ -564,7 +564,7 @@ def test_reference_bad_string_id():
564564
@staticmethod
565565
@pytest.mark.usefixtures("in_context")
566566
def test_reference_bad_integer_id():
567-
for id_ in (-10, 0, 2 ** 64):
567+
for id_ in (-10, 0, 2**64):
568568
key = key_module.Key("kind", id_, app="app")
569569
with pytest.raises(ValueError):
570570
key.reference()

packages/google-cloud-ndb/tests/unit/test_model.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ def test_repr():
19551955
@staticmethod
19561956
def test__validate():
19571957
prop = model.CompressedTextProperty(name="text")
1958-
assert prop._validate(u"abc") is None
1958+
assert prop._validate("abc") is None
19591959

19601960
@staticmethod
19611961
def test__validate_bad_bytes():
@@ -1979,18 +1979,18 @@ def test__to_base_type():
19791979
def test__to_base_type_converted():
19801980
prop = model.CompressedTextProperty(name="text")
19811981
value = b"\xe2\x98\x83"
1982-
assert prop._to_base_type(u"\N{snowman}") == value
1982+
assert prop._to_base_type("\N{snowman}") == value
19831983

19841984
@staticmethod
19851985
def test__from_base_type():
19861986
prop = model.CompressedTextProperty(name="text")
1987-
assert prop._from_base_type(u"abc") is None
1987+
assert prop._from_base_type("abc") is None
19881988

19891989
@staticmethod
19901990
def test__from_base_type_converted():
19911991
prop = model.CompressedTextProperty(name="text")
19921992
value = b"\xe2\x98\x83"
1993-
assert prop._from_base_type(value) == u"\N{snowman}"
1993+
assert prop._from_base_type(value) == "\N{snowman}"
19941994

19951995
@staticmethod
19961996
def test__from_base_type_cannot_convert():
@@ -2054,24 +2054,24 @@ def test__validate_bad_type():
20542054
@staticmethod
20552055
def test__to_base_type():
20562056
prop = model.TextProperty(name="text")
2057-
assert prop._to_base_type(u"abc") is None
2057+
assert prop._to_base_type("abc") is None
20582058

20592059
@staticmethod
20602060
def test__to_base_type_converted():
20612061
prop = model.TextProperty(name="text")
2062-
value = u"\N{snowman}"
2062+
value = "\N{snowman}"
20632063
assert prop._to_base_type(b"\xe2\x98\x83") == value
20642064

20652065
@staticmethod
20662066
def test__from_base_type():
20672067
prop = model.TextProperty(name="text")
2068-
assert prop._from_base_type(u"abc") is None
2068+
assert prop._from_base_type("abc") is None
20692069

20702070
@staticmethod
20712071
def test__from_base_type_converted():
20722072
prop = model.TextProperty(name="text")
20732073
value = b"\xe2\x98\x83"
2074-
assert prop._from_base_type(value) == u"\N{snowman}"
2074+
assert prop._from_base_type(value) == "\N{snowman}"
20752075

20762076
@staticmethod
20772077
def test__from_base_type_cannot_convert():
@@ -2222,22 +2222,22 @@ def test__validate_incorrect_type():
22222222
@staticmethod
22232223
def test__to_base_type():
22242224
prop = model.JsonProperty(name="json-val")
2225-
value = [14, [15, 16], {"seventeen": 18}, u"\N{snowman}"]
2225+
value = [14, [15, 16], {"seventeen": 18}, "\N{snowman}"]
22262226
expected = b'[14,[15,16],{"seventeen":18},"\\u2603"]'
22272227
assert prop._to_base_type(value) == expected
22282228

22292229
@staticmethod
22302230
def test__from_base_type():
22312231
prop = model.JsonProperty(name="json-val")
22322232
value = b'[14,true,{"a":null,"b":"\\u2603"}]'
2233-
expected = [14, True, {"a": None, "b": u"\N{snowman}"}]
2233+
expected = [14, True, {"a": None, "b": "\N{snowman}"}]
22342234
assert prop._from_base_type(value) == expected
22352235

22362236
@staticmethod
22372237
def test__from_base_type_str():
22382238
prop = model.JsonProperty(name="json-val")
2239-
value = u'[14,true,{"a":null,"b":"\\u2603"}]'
2240-
expected = [14, True, {"a": None, "b": u"\N{snowman}"}]
2239+
value = '[14,true,{"a":null,"b":"\\u2603"}]'
2240+
expected = [14, True, {"a": None, "b": "\N{snowman}"}]
22412241
assert prop._from_base_type(value) == expected
22422242

22432243

@@ -2338,16 +2338,13 @@ def test__from_ds_entity():
23382338

23392339
@staticmethod
23402340
def test__from_ds_entity_with_user_id():
2341-
assert (
2342-
model.User._from_ds_entity(
2343-
{
2344-
"email": "foo@example.com",
2345-
"auth_domain": "gmail.com",
2346-
"user_id": "12345",
2347-
}
2348-
)
2349-
== model.User("foo@example.com", "gmail.com", "12345")
2350-
)
2341+
assert model.User._from_ds_entity(
2342+
{
2343+
"email": "foo@example.com",
2344+
"auth_domain": "gmail.com",
2345+
"user_id": "12345",
2346+
}
2347+
) == model.User("foo@example.com", "gmail.com", "12345")
23512348

23522349

23532350
class TestUserProperty:
@@ -3151,8 +3148,8 @@ class Mine(model.Model):
31513148
mine = Mine(foo="x", bar="y")
31523149
comparison = prop._comparison("=", mine)
31533150
compared = query_module.AND(
3154-
query_module.FilterNode("baz.bar", "=", u"y"),
3155-
query_module.FilterNode("baz.foo", "=", u"x"),
3151+
query_module.FilterNode("baz.bar", "=", "y"),
3152+
query_module.FilterNode("baz.foo", "=", "x"),
31563153
)
31573154
# Python 2 and 3 order nodes differently, sort them and test each one
31583155
# is in both lists.
@@ -3182,8 +3179,8 @@ class Mine(model.Model):
31823179
conjunction_nodes = sorted(
31833180
conjunction._nodes, key=lambda a: getattr(a, "_name", "z")
31843181
)
3185-
assert conjunction_nodes[0] == query_module.FilterNode("bar.bar", "=", u"y")
3186-
assert conjunction_nodes[1] == query_module.FilterNode("bar.foo", "=", u"x")
3182+
assert conjunction_nodes[0] == query_module.FilterNode("bar.bar", "=", "y")
3183+
assert conjunction_nodes[1] == query_module.FilterNode("bar.foo", "=", "x")
31873184
assert conjunction_nodes[2].predicate.name == "bar"
31883185
assert sorted(conjunction_nodes[2].predicate.match_keys) == [
31893186
"bar",
@@ -3940,7 +3937,7 @@ def test__validate_indexed_bytes():
39403937
@staticmethod
39413938
def test__validate_indexed_unicode():
39423939
prop = model.GenericProperty(name="generic", indexed=True)
3943-
assert prop._validate(u"abc") is None
3940+
assert prop._validate("abc") is None
39443941

39453942
@staticmethod
39463943
def test__validate_indexed_bad_length():

packages/google-cloud-ndb/tests/unit/test_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class SubKind(model.Model):
180180
class SomeKind(model.Model):
181181
foo = model.StructuredProperty(SubKind, repeated=True)
182182

183-
match_entity = SubKind(bar=1, baz=u"scoggs")
183+
match_entity = SubKind(bar=1, baz="scoggs")
184184
predicate = query_module.RepeatedStructuredPropertyPredicate(
185185
"foo", ["bar", "baz"], model._entity_to_protobuf(match_entity)
186186
)
@@ -191,7 +191,7 @@ class SomeKind(model.Model):
191191
{
192192
"something.else": "whocares",
193193
"foo.bar": [2, 1],
194-
"foo.baz": [u"matic", u"scoggs"],
194+
"foo.baz": ["matic", "scoggs"],
195195
}
196196
)
197197

0 commit comments

Comments
 (0)