Skip to content

Commit cb54ac1

Browse files
committed
993 mypy also gettin rough
1 parent 1b7fe67 commit cb54ac1

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

tests/extensions/test_custom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests creating a custom extension"""
22

3+
from collections.abc import Generator
34
from datetime import datetime
45
from typing import Any, Generic, TypeVar, cast
56

@@ -119,7 +120,7 @@ def migrate(
119120

120121

121122
@pytest.fixture
122-
def add_extension_hooks() -> None:
123+
def add_extension_hooks() -> Generator[None]:
123124
pystac.EXTENSION_HOOKS.add_extension_hooks(CustomExtensionHooks())
124125
yield
125126
pystac.EXTENSION_HOOKS.remove_extension_hooks(SCHEMA_URI)

tests/extensions/test_eo.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ def test_to_from_dict() -> None:
5252
assert_to_from_dict(Item, item_dict)
5353

5454

55+
def test_from_file_to_dict(ext_item_uri: str, ext_item: pystac.Item) -> None:
56+
with open(ext_item_uri) as f:
57+
d = json.load(f)
58+
actual = ext_item.to_dict(include_self_link=False)
59+
assert actual == d
60+
61+
5562
def test_add_to() -> None:
5663
item = Item.from_file(PLAIN_ITEM)
5764
assert EOExtension.get_schema_uri() not in item.stac_extensions
@@ -283,7 +290,7 @@ def test_item_apply() -> None:
283290
test_band = Band.create(name="test")
284291

285292
assert eo_ext.cloud_cover == 78
286-
assert test_band not in eo_ext.bands or []
293+
assert test_band not in (eo_ext.bands or [])
287294

288295
eo_ext.apply(bands=[test_band], cloud_cover=15)
289296
assert eo_ext.bands is not None
@@ -380,13 +387,6 @@ def ext_item(ext_item_uri: str) -> pystac.Item:
380387
return pystac.Item.from_file(ext_item_uri)
381388

382389

383-
def test_to_from_dict(ext_item_uri: str, ext_item: pystac.Item) -> None:
384-
with open(ext_item_uri) as f:
385-
d = json.load(f)
386-
actual = ext_item.to_dict(include_self_link=False)
387-
assert actual == d
388-
389-
390390
@pytest.mark.parametrize("field", ["cloud_cover", "snow_cover"])
391391
def test_get_field(ext_item: pystac.Item, field: str) -> None:
392392
prop = ext_item.properties[f"{PREFIX}{field}"]

tests/extensions/test_pointcloud.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def example_uri() -> str:
2626

2727

2828
@pytest.fixture
29-
def pc_item(example_uri) -> pystac.Item:
29+
def pc_item(example_uri: str) -> pystac.Item:
3030
return pystac.Item.from_file(example_uri)
3131

3232

@@ -274,7 +274,7 @@ def test_pointcloud_statistics() -> None:
274274

275275

276276
def test_statistics_accessor_when_no_stats(pc_no_stats_item: pystac.Item) -> None:
277-
assert PointcloudExtension.ext(pc_no_stats_item).statistics == None
277+
assert PointcloudExtension.ext(pc_no_stats_item).statistics is None
278278

279279

280280
def test_asset_extension(pc_no_stats_item: pystac.Item) -> None:

0 commit comments

Comments
 (0)