Skip to content

Commit

Permalink
Devex: Update Black and Flake8 (#12502)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 1631eb281745505e89a7720b49dae434df81b2db
  • Loading branch information
stephencpope authored and Descartes Labs Build committed Mar 21, 2024
1 parent 5526804 commit 836696e
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 18 deletions.
8 changes: 5 additions & 3 deletions descarteslabs/core/catalog/band.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,11 @@ def serialize(self, value, jsonapi_format=False):

# Shallow copy for strings, deserialize ListAttributes
return {
k: v
if isinstance(v, str)
else v.serialize(v, jsonapi_format=jsonapi_format)
k: (
v
if isinstance(v, str)
else v.serialize(v, jsonapi_format=jsonapi_format)
)
for k, v in value.items()
}

Expand Down
2 changes: 1 addition & 1 deletion descarteslabs/core/catalog/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _serialize_filters(self):
serialized = self._filter_properties.jsonapi_serialize(self._model_cls)
# Flatten top-level "and" expressions since they are fairly common, e.g.
# if you call filter() multiple times.
if type(self._filter_properties) == AndExpression:
if type(self._filter_properties) is AndExpression:
for f in serialized["and"]:
filters.append(f)
else:
Expand Down
4 changes: 2 additions & 2 deletions descarteslabs/core/catalog/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def sort_filters(self, filters):
Sort all lists in filter definitions in a more or less stable way
in place for comparison.
"""
if type(filters) == list:
if type(filters) is list:
filters.sort(
key=lambda i: (
len(i.get("and", [])),
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_search(self):
)
results = list(self.search)
assert len(results) == 1
assert type(results[0]) == Product
assert type(results[0]) is Product
# followed continuation token
assert responses.calls[0].request.url == self.url + "/products"
assert (
Expand Down
2 changes: 1 addition & 1 deletion descarteslabs/core/common/client/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _serialize(self, json_encode: bool = True) -> dict:
filters = []
filter = self._filters.jsonapi_serialize(self._document)

if type(self._filters) == AndExpression:
if type(self._filters) is AndExpression:
for f in filter["and"]:
filters.append(f)
else:
Expand Down
4 changes: 2 additions & 2 deletions descarteslabs/core/common/dltile/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def lonlat_to_rowcol(
lat: Union[float, Sequence[float]],
):
"""Convert lonlat coordinates to pixel coordinates"""
if type(lon) != type(lat):
if type(lon) is not type(lat):
raise InvalidLatLonError("lat and lon should have compatible types")

if isinstance(lon, (collections.abc.Sequence, np.ndarray)):
Expand All @@ -497,7 +497,7 @@ def rowcol_to_lonlat(
col: Union[int, Sequence[int]],
):
"""Convert pixel coordinates to lonlat coordinates"""
if type(row) != type(col):
if type(row) is not type(col):
raise InvalidRowColError("row and col should have compatible types")

if isinstance(row, (collections.abc.Sequence, np.ndarray)):
Expand Down
8 changes: 4 additions & 4 deletions descarteslabs/core/common/dotdict/tests/test_dotdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,16 @@ def test_basic(self):
d = DotDict({"a": 1, "b": 2})

unboxed = d.asdict()
assert type(unboxed) == dict
assert type(unboxed) is dict
assert unboxed == d

obj = DotDict(a=d)
unboxed = obj.asdict()
assert type(unboxed["a"]) == dict
assert type(unboxed["a"]) is dict

obj = DotList(DotDict(i=i) for i in range(10))
unboxed = obj.aslist()
assert type(unboxed) == list
assert type(unboxed) is list
assert all(type(x) is dict for x in unboxed)

obj = DotDict({i: DotList(range(i)) for i in range(10)})
Expand Down Expand Up @@ -289,7 +289,7 @@ def test_recursive_container(self):

d.loop = d
unboxed = d.asdict()
assert type(unboxed["loop"]) == dict
assert type(unboxed["loop"]) is dict


class TestDotList(unittest.TestCase):
Expand Down
10 changes: 5 additions & 5 deletions descarteslabs/core/common/geo/tests/test_geocontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ def test_iter_from_shape(self):
}
dltiles1 = [tile for tile in geocontext.DLTile.iter_from_shape(shape, **params)]
dltiles2 = geocontext.DLTile.from_shape(shape, **params)
assert type(dltiles1[0]) == str
assert type(dltiles1[1]) == str
assert type(dltiles1[0]) is str
assert type(dltiles1[1]) is str
assert len(dltiles1) == len(dltiles2)

def test_iter_from_shape_multi(self):
Expand Down Expand Up @@ -426,15 +426,15 @@ def test_iter_from_shape_multi(self):
}
dltiles1 = [tile for tile in geocontext.DLTile.iter_from_shape(shape, **params)]
dltiles2 = geocontext.DLTile.from_shape(shape, **params)
assert type(dltiles1[0]) == str
assert type(dltiles1[1]) == str
assert type(dltiles1[0]) is str
assert type(dltiles1[1]) is str
assert len(dltiles1) == len(dltiles2)

def test_subtile(self):
tile = geocontext.DLTile.from_key("2048:0:30.0:15:3:80")
tiles = [t for t in tile.subtile(8, keys_only=True)]
assert len(tiles) == 64
assert type(tiles[0]) == str
assert type(tiles[0]) is str


class TestXYZTile(unittest.TestCase):
Expand Down
1 change: 1 addition & 0 deletions docs/examples/plot_create_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
This example demonstrates how to create a product
in our Catalog and upload an example image.
"""

from descarteslabs.catalog import Product, SpectralBand, Image, properties as p
import uuid

Expand Down
1 change: 1 addition & 0 deletions docs/examples/plot_images_mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

from descarteslabs.catalog import Product, properties as p
from descarteslabs.geo import DLTile
from descarteslabs.utils import display
Expand Down
1 change: 1 addition & 0 deletions docs/examples/plot_timestacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
This example demonstrates how to aggregate the images returned from a Catalog image search by date.
"""

from descarteslabs.catalog import Product, properties as p
from descarteslabs.utils import display

Expand Down

0 comments on commit 836696e

Please sign in to comment.