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

Bump pystac version, remove some type: ignores, and do some other linting #449

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Changed

- Bumped PySTAC dependency to >= 1.7.0 [#449](https://github.com/stac-utils/pystac-client/pull/449)

### Fixed

- Fix parse fail when header has multiple '=' characters [#440](https://github.com/stac-utils/pystac-client/pull/440)
Expand Down
18 changes: 2 additions & 16 deletions pystac_client/client.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
from functools import lru_cache
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Union,
cast,
)
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Union

import pystac
import pystac.utils
Expand Down Expand Up @@ -204,7 +194,7 @@ def from_file( # type: ignore
request_modifier=request_modifier,
)

client: Client = super().from_file(href, stac_io) # type: ignore
client: Client = super().from_file(href, stac_io)

client._stac_io._conformance = client.extra_fields.get( # type: ignore
"conformsTo", []
Expand Down Expand Up @@ -241,10 +231,6 @@ def from_dict(
f"Could not open Client (href={href}), "
f"expected type=Catalog, found type={d.get('type', None)}"
)
# cast require for mypy to believe that we have a Client, rather than
# the super type.
# https://github.com/stac-utils/pystac/issues/862
result = cast(Client, result)

result.modifier = modifier
return result
Expand Down
4 changes: 1 addition & 3 deletions pystac_client/collection_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class CollectionClient(pystac.Collection):

modifier: Callable[[Modifiable], None]
_stac_io: Optional[StacApiIO]

Expand Down Expand Up @@ -69,8 +68,7 @@ def from_dict(
# error: Cannot assign to a method [assignment]
# https://github.com/python/mypy/issues/2427
setattr(result, "modifier", modifier)
# ignore the return type: https://github.com/stac-utils/pystac/issues/862
return result # type: ignore
return result

def __repr__(self) -> str:
return "<CollectionClient id={}>".format(self.id)
Expand Down
2 changes: 1 addition & 1 deletion requirements-min.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
requests==2.28.2
pystac==1.4.0
pystac==1.7.0
python-dateutil==2.7.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
python_requires=">=3.8",
install_requires=[
"requests>=2.27.1",
"pystac>=1.4.0",
"pystac>=1.7.0",
"python-dateutil>=2.7.0",
],
extras_require={"validation": ["jsonschema>=4.5.1"]},
Expand Down
10 changes: 5 additions & 5 deletions tests/test_item_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
class TestItemPerformance:
@pytest.fixture(scope="function")
def single_href(self) -> str:
item_href = "https://planetarycomputer.microsoft.com/api/stac/v1/collections/{collections}/items/{ids}".format(
collections=ITEM_EXAMPLE["collections"], ids=ITEM_EXAMPLE["ids"]
item_href = (
"https://planetarycomputer.microsoft.com/api/stac/v1/collections/"
f"{ITEM_EXAMPLE['collections']}/items/{ITEM_EXAMPLE['ids']}"
)
return item_href

Expand Down Expand Up @@ -457,7 +458,6 @@ def test_sortby(self) -> None:
ItemSearch(url=SEARCH_URL, sortby=[1]) # type: ignore

def test_fields(self) -> None:

with pytest.raises(Exception):
ItemSearch(url=SEARCH_URL, fields=1) # type: ignore

Expand Down Expand Up @@ -629,7 +629,8 @@ def test_result_paging(self) -> None:
max_items=20,
)

# Check that the current page changes on the ItemSearch instance when a new page is requested
# Check that the current page changes on the ItemSearch instance when a new page
# is requested
pages = list(search.pages())

assert pages[1] != pages[2]
Expand Down Expand Up @@ -725,7 +726,6 @@ def test_query_shortcut_syntax(self) -> None:

@pytest.mark.vcr
def test_query_json_syntax(self) -> None:

# with a list of json strs (format of CLI argument to ItemSearch)
search = ItemSearch(
url=SEARCH_URL,
Expand Down