Skip to content

Commit

Permalink
chore: pyupgrade v3.10 (#783)
Browse files Browse the repository at this point in the history
* chore: pyupgrade v3.10

* chore: update changelog
  • Loading branch information
gadomski authored Feb 3, 2025
1 parent 1b16191 commit 605e95c
Show file tree
Hide file tree
Showing 18 changed files with 270 additions and 296 deletions.
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

- Updated to Python 3.10 syntax with **pyupgrade** [#783](https://github.com/stac-utils/pystac-client/pull/783/)

### Fixed

- `Client.get_collection` for static catalogs [#782](https://github.com/stac-utils/pystac-client/pull/782)
Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import subprocess
import sys
from pathlib import Path
from typing import List

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -112,7 +111,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path: List[str] = ["_static"]
html_static_path: list[str] = ["_static"]


# -- Options for intersphinx extension ---------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions pystac_client/_utils.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import urllib
import warnings
from typing import Any, Callable, Dict, Optional, Union
from collections.abc import Callable
from typing import Any, Union

import pystac

from pystac_client.errors import IgnoredResultWarning

Modifiable = Union[
pystac.Collection, pystac.Item, pystac.ItemCollection, Dict[Any, Any]
pystac.Collection, pystac.Item, pystac.ItemCollection, dict[Any, Any]
]


def call_modifier(
modifier: Optional[Callable[[Modifiable], None]], obj: Modifiable
modifier: Callable[[Modifiable], None] | None, obj: Modifiable
) -> None:
"""Calls the user's modifier and validates that the result is None."""
if modifier is None:
Expand Down
56 changes: 28 additions & 28 deletions pystac_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
import sys
import warnings
from typing import Any, Dict, List, Optional
from typing import Any

from pystac import STACError, STACTypeError

Expand Down Expand Up @@ -39,21 +39,21 @@
def search(
client: Client,
matched: bool = False,
save: Optional[str] = None,
save: str | None = None,
*,
method: str = "GET",
max_items: Optional[int] = None,
limit: Optional[int] = None,
ids: Optional[IDsLike] = None,
collections: Optional[CollectionsLike] = None,
bbox: Optional[BBoxLike] = None,
intersects: Optional[IntersectsLike] = None,
datetime: Optional[DatetimeLike] = None,
query: Optional[QueryLike] = None,
filter: Optional[FilterLike] = None,
filter_lang: Optional[FilterLangLike] = None,
sortby: Optional[SortbyLike] = None,
fields: Optional[FieldsLike] = None,
max_items: int | None = None,
limit: int | None = None,
ids: IDsLike | None = None,
collections: CollectionsLike | None = None,
bbox: BBoxLike | None = None,
intersects: IntersectsLike | None = None,
datetime: DatetimeLike | None = None,
query: QueryLike | None = None,
filter: FilterLike | None = None,
filter_lang: FilterLangLike | None = None,
sortby: SortbyLike | None = None,
fields: FieldsLike | None = None,
) -> int:
"""Main function for performing a search"""

Expand Down Expand Up @@ -90,19 +90,19 @@ def search(

def collections(
client: Client,
save: Optional[str] = None,
save: str | None = None,
matched: bool = False,
*,
max_collections: Optional[int] = None,
limit: Optional[int] = None,
bbox: Optional[BBoxLike] = None,
datetime: Optional[DatetimeLike] = None,
q: Optional[str] = None,
query: Optional[QueryLike] = None,
filter: Optional[FilterLike] = None,
filter_lang: Optional[FilterLangLike] = None,
sortby: Optional[SortbyLike] = None,
fields: Optional[FieldsLike] = None,
max_collections: int | None = None,
limit: int | None = None,
bbox: BBoxLike | None = None,
datetime: DatetimeLike | None = None,
q: str | None = None,
query: QueryLike | None = None,
filter: FilterLike | None = None,
filter_lang: FilterLangLike | None = None,
sortby: SortbyLike | None = None,
fields: FieldsLike | None = None,
) -> int:
"""Fetch collections from collections endpoint"""
try:
Expand Down Expand Up @@ -164,7 +164,7 @@ def add_warnings_behavior(parser: argparse.ArgumentParser) -> None:
)


def set_warnings(error: Optional[List[str]], ignore: Optional[List[str]]) -> None:
def set_warnings(error: list[str] | None, ignore: list[str] | None) -> None:
# First set filters on the base class
if ignore is not None and len(ignore) == 0:
warnings.filterwarnings("ignore", category=PystacClientWarning)
Expand All @@ -187,7 +187,7 @@ def set_warnings(error: Optional[List[str]], ignore: Optional[List[str]]) -> Non


def set_conforms_to(
client: Client, clear: bool, remove: Optional[List[str]], add: Optional[List[str]]
client: Client, clear: bool, remove: list[str] | None, add: list[str] | None
) -> None:
"""Alters conforms_to settings on client in-place"""
if clear:
Expand All @@ -200,7 +200,7 @@ def set_conforms_to(
client.add_conforms_to(conformance_class)


def parse_args(args: List[str]) -> Dict[str, Any]:
def parse_args(args: list[str]) -> dict[str, Any]:
desc = "STAC Client"
dhf = argparse.ArgumentDefaultsHelpFormatter
parser0 = argparse.ArgumentParser(description=desc)
Expand Down
Loading

0 comments on commit 605e95c

Please sign in to comment.