Skip to content

Commit 605e95c

Browse files
authored
chore: pyupgrade v3.10 (#783)
* chore: pyupgrade v3.10 * chore: update changelog
1 parent 1b16191 commit 605e95c

18 files changed

+270
-296
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Updated to Python 3.10 syntax with **pyupgrade** [#783](https://github.com/stac-utils/pystac-client/pull/783/)
13+
1014
### Fixed
1115

1216
- `Client.get_collection` for static catalogs [#782](https://github.com/stac-utils/pystac-client/pull/782)

docs/conf.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import subprocess
99
import sys
1010
from pathlib import Path
11-
from typing import List
1211

1312
# -- Path setup --------------------------------------------------------------
1413

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

117116

118117
# -- Options for intersphinx extension ---------------------------------------

pystac_client/_utils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import urllib
22
import warnings
3-
from typing import Any, Callable, Dict, Optional, Union
3+
from collections.abc import Callable
4+
from typing import Any, Union
45

56
import pystac
67

78
from pystac_client.errors import IgnoredResultWarning
89

910
Modifiable = Union[
10-
pystac.Collection, pystac.Item, pystac.ItemCollection, Dict[Any, Any]
11+
pystac.Collection, pystac.Item, pystac.ItemCollection, dict[Any, Any]
1112
]
1213

1314

1415
def call_modifier(
15-
modifier: Optional[Callable[[Modifiable], None]], obj: Modifiable
16+
modifier: Callable[[Modifiable], None] | None, obj: Modifiable
1617
) -> None:
1718
"""Calls the user's modifier and validates that the result is None."""
1819
if modifier is None:

pystac_client/cli.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import sys
77
import warnings
8-
from typing import Any, Dict, List, Optional
8+
from typing import Any
99

1010
from pystac import STACError, STACTypeError
1111

@@ -39,21 +39,21 @@
3939
def search(
4040
client: Client,
4141
matched: bool = False,
42-
save: Optional[str] = None,
42+
save: str | None = None,
4343
*,
4444
method: str = "GET",
45-
max_items: Optional[int] = None,
46-
limit: Optional[int] = None,
47-
ids: Optional[IDsLike] = None,
48-
collections: Optional[CollectionsLike] = None,
49-
bbox: Optional[BBoxLike] = None,
50-
intersects: Optional[IntersectsLike] = None,
51-
datetime: Optional[DatetimeLike] = None,
52-
query: Optional[QueryLike] = None,
53-
filter: Optional[FilterLike] = None,
54-
filter_lang: Optional[FilterLangLike] = None,
55-
sortby: Optional[SortbyLike] = None,
56-
fields: Optional[FieldsLike] = None,
45+
max_items: int | None = None,
46+
limit: int | None = None,
47+
ids: IDsLike | None = None,
48+
collections: CollectionsLike | None = None,
49+
bbox: BBoxLike | None = None,
50+
intersects: IntersectsLike | None = None,
51+
datetime: DatetimeLike | None = None,
52+
query: QueryLike | None = None,
53+
filter: FilterLike | None = None,
54+
filter_lang: FilterLangLike | None = None,
55+
sortby: SortbyLike | None = None,
56+
fields: FieldsLike | None = None,
5757
) -> int:
5858
"""Main function for performing a search"""
5959

@@ -90,19 +90,19 @@ def search(
9090

9191
def collections(
9292
client: Client,
93-
save: Optional[str] = None,
93+
save: str | None = None,
9494
matched: bool = False,
9595
*,
96-
max_collections: Optional[int] = None,
97-
limit: Optional[int] = None,
98-
bbox: Optional[BBoxLike] = None,
99-
datetime: Optional[DatetimeLike] = None,
100-
q: Optional[str] = None,
101-
query: Optional[QueryLike] = None,
102-
filter: Optional[FilterLike] = None,
103-
filter_lang: Optional[FilterLangLike] = None,
104-
sortby: Optional[SortbyLike] = None,
105-
fields: Optional[FieldsLike] = None,
96+
max_collections: int | None = None,
97+
limit: int | None = None,
98+
bbox: BBoxLike | None = None,
99+
datetime: DatetimeLike | None = None,
100+
q: str | None = None,
101+
query: QueryLike | None = None,
102+
filter: FilterLike | None = None,
103+
filter_lang: FilterLangLike | None = None,
104+
sortby: SortbyLike | None = None,
105+
fields: FieldsLike | None = None,
106106
) -> int:
107107
"""Fetch collections from collections endpoint"""
108108
try:
@@ -164,7 +164,7 @@ def add_warnings_behavior(parser: argparse.ArgumentParser) -> None:
164164
)
165165

166166

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

188188

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

202202

203-
def parse_args(args: List[str]) -> Dict[str, Any]:
203+
def parse_args(args: list[str]) -> dict[str, Any]:
204204
desc = "STAC Client"
205205
dhf = argparse.ArgumentDefaultsHelpFormatter
206206
parser0 = argparse.ArgumentParser(description=desc)

0 commit comments

Comments
 (0)