Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute code has type str but is used as type None #878

Merged
merged 7 commits into from
Dec 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tests/extensions/test_grid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Tests for pystac.extensions.grid."""
# This is for the type checking on GridTest.test_clear_code
# mypy: warn_unused_ignores=False

import datetime
from typing import Any, Dict
Expand Down Expand Up @@ -86,7 +88,22 @@ def test_clear_code(self) -> None:
GridExtension.ext(self.item).apply(code)

with self.assertRaises(ValueError):
GridExtension.ext(self.item).code = None
# Ignore type errors because this test intentionally checks behavior
# that does not conform to the type signature.
# https://github.com/stac-utils/pystac/pull/878#discussion_r957352232
GridExtension.ext(self.item).code = None # type: ignore
with self.assertRaises(ValueError):
# First segment has to be all caps
# https://github.com/stac-utils/pystac/pull/878#discussion_r957354927
GridExtension.ext(self.item).code = "this-is-not-a-grid-code"
with self.assertRaises(ValueError):
# Folks might try to put an epsg code in
# https://github.com/stac-utils/pystac/pull/878#discussion_r957355415
GridExtension.ext(self.item).code = "4326"
with self.assertRaises(ValueError):
# Folks might try to put an epsg code in
# https://github.com/stac-utils/pystac/pull/878#discussion_r957355415
GridExtension.ext(self.item).code = "EPSG:4326"

def test_extension_not_implemented(self) -> None:
# Should raise exception if Item does not include extension URI
Expand Down