Skip to content

Commit 55232c8

Browse files
committed
refactor: Change some set() calls into literals
Also removed their type annotations since they were inferred by mypy.
1 parent 83a6598 commit 55232c8

File tree

14 files changed

+51
-58
lines changed

14 files changed

+51
-58
lines changed

pystac/extensions/datacube.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
from abc import ABC
7-
from typing import Any, Dict, Generic, List, Optional, Set, TypeVar, Union, cast
7+
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union, cast
88

99
import pystac
1010
from pystac.extensions.base import (
@@ -403,10 +403,11 @@ def __repr__(self) -> str:
403403

404404
class DatacubeExtensionHooks(ExtensionHooks):
405405
schema_uri: str = SCHEMA_URI
406-
prev_extension_ids: Set[str] = set(["datacube"])
407-
stac_object_types: Set[pystac.STACObjectType] = set(
408-
[pystac.STACObjectType.COLLECTION, pystac.STACObjectType.ITEM]
409-
)
406+
prev_extension_ids = {"datacube"}
407+
stac_object_types = {
408+
pystac.STACObjectType.COLLECTION,
409+
pystac.STACObjectType.ITEM,
410+
}
410411

411412

412413
DATACUBE_EXTENSION_HOOKS: ExtensionHooks = DatacubeExtensionHooks()

pystac/extensions/eo.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
Iterable,
1111
List,
1212
Optional,
13-
Set,
1413
Tuple,
1514
TypeVar,
1615
cast,
@@ -498,8 +497,8 @@ def cloud_cover(self, v: Optional[RangeSummary[float]]) -> None:
498497

499498
class EOExtensionHooks(ExtensionHooks):
500499
schema_uri: str = SCHEMA_URI
501-
prev_extension_ids: Set[str] = set(["eo"])
502-
stac_object_types: Set[pystac.STACObjectType] = set([pystac.STACObjectType.ITEM])
500+
prev_extension_ids = {"eo"}
501+
stac_object_types = {pystac.STACObjectType.ITEM}
503502

504503
def migrate(
505504
self, obj: Dict[str, Any], version: STACVersionID, info: STACJSONDescription

pystac/extensions/file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
from enum import Enum
7-
from typing import Any, Dict, List, Optional, Set
7+
from typing import Any, Dict, List, Optional
88

99
import pystac
1010
from pystac.extensions.base import ExtensionManagementMixin, PropertiesExtension
@@ -212,8 +212,8 @@ def ext(cls, obj: pystac.Asset, add_if_missing: bool = False) -> "FileExtension"
212212

213213
class FileExtensionHooks(ExtensionHooks):
214214
schema_uri: str = SCHEMA_URI
215-
prev_extension_ids: Set[str] = set(["file"])
216-
stac_object_types: Set[pystac.STACObjectType] = set([pystac.STACObjectType.ITEM])
215+
prev_extension_ids = {"file"}
216+
stac_object_types = {pystac.STACObjectType.ITEM}
217217

218218
def migrate(
219219
self, obj: Dict[str, Any], version: STACVersionID, info: STACJSONDescription

pystac/extensions/item_assets.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://github.com/stac-extensions/item-assets
44
"""
55

6-
from typing import Any, Dict, List, Optional, Set
6+
from typing import Any, Dict, List, Optional
77

88
import pystac
99
from pystac.extensions.base import ExtensionManagementMixin
@@ -80,14 +80,12 @@ def create_asset(self, href: str) -> pystac.Asset:
8080
k: v
8181
for k, v in self.properties.items()
8282
if k
83-
not in set(
84-
[
85-
ASSET_TITLE_PROP,
86-
ASSET_DESC_PROP,
87-
ASSET_TYPE_PROP,
88-
ASSET_ROLES_PROP,
89-
]
90-
)
83+
not in {
84+
ASSET_TITLE_PROP,
85+
ASSET_DESC_PROP,
86+
ASSET_TYPE_PROP,
87+
ASSET_ROLES_PROP,
88+
}
9189
},
9290
)
9391

@@ -132,10 +130,8 @@ def ext(
132130

133131
class ItemAssetsExtensionHooks(ExtensionHooks):
134132
schema_uri: str = SCHEMA_URI
135-
prev_extension_ids: Set[str] = set(["asset", "item-assets"])
136-
stac_object_types: Set[pystac.STACObjectType] = set(
137-
[pystac.STACObjectType.COLLECTION]
138-
)
133+
prev_extension_ids = {"asset", "item-assets"}
134+
stac_object_types = {pystac.STACObjectType.COLLECTION}
139135

140136
def migrate(
141137
self, obj: Dict[str, Any], version: STACVersionID, info: STACJSONDescription

pystac/extensions/label.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from enum import Enum
77
from pystac.extensions.base import ExtensionManagementMixin, SummariesExtension
8-
from typing import Any, Dict, Iterable, List, Optional, Set, Union, cast
8+
from typing import Any, Dict, Iterable, List, Optional, Union, cast
99

1010
import pystac
1111
from pystac.serialization.identify import STACJSONDescription, STACVersionID
@@ -793,8 +793,8 @@ def label_methods(self, v: Optional[List[Union[LabelMethod, str]]]) -> None:
793793

794794
class LabelExtensionHooks(ExtensionHooks):
795795
schema_uri: str = SCHEMA_URI
796-
prev_extension_ids: Set[str] = set(["label"])
797-
stac_object_types: Set[pystac.STACObjectType] = set([pystac.STACObjectType.ITEM])
796+
prev_extension_ids = {"label"}
797+
stac_object_types = {pystac.STACObjectType.ITEM}
798798

799799
def get_object_links(
800800
self, so: pystac.STACObject

pystac/extensions/pointcloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://github.com/stac-extensions/pointcloud
44
"""
55

6-
from typing import Any, Dict, Generic, List, Optional, Set, TypeVar, cast
6+
from typing import Any, Dict, Generic, List, Optional, TypeVar, cast
77

88
import pystac
99
from pystac.extensions.base import (
@@ -565,8 +565,8 @@ def __repr__(self) -> str:
565565

566566
class PointcloudExtensionHooks(ExtensionHooks):
567567
schema_uri: str = SCHEMA_URI
568-
prev_extension_ids: Set[str] = set(["pointcloud"])
569-
stac_object_types: Set[pystac.STACObjectType] = set([pystac.STACObjectType.ITEM])
568+
prev_extension_ids = {"pointcloud"}
569+
stac_object_types = {pystac.STACObjectType.ITEM}
570570

571571

572572
POINTCLOUD_EXTENSION_HOOKS: ExtensionHooks = PointcloudExtensionHooks()

pystac/extensions/projection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://github.com/stac-extensions/projection
44
"""
55

6-
from typing import Any, Dict, Generic, Iterable, List, Optional, Set, TypeVar, cast
6+
from typing import Any, Dict, Generic, Iterable, List, Optional, TypeVar, cast
77

88
import pystac
99
from pystac.extensions.hooks import ExtensionHooks
@@ -342,8 +342,8 @@ def epsg(self, v: Optional[List[int]]) -> None:
342342

343343
class ProjectionExtensionHooks(ExtensionHooks):
344344
schema_uri: str = SCHEMA_URI
345-
prev_extension_ids: Set[str] = set(["proj", "projection"])
346-
stac_object_types: Set[pystac.STACObjectType] = set([pystac.STACObjectType.ITEM])
345+
prev_extension_ids = {"proj", "projection"}
346+
stac_object_types = {pystac.STACObjectType.ITEM}
347347

348348

349349
PROJECTION_EXTENSION_HOOKS: ExtensionHooks = ProjectionExtensionHooks()

pystac/extensions/sar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
import enum
7-
from typing import Any, Dict, Generic, List, Optional, Set, TypeVar, cast
7+
from typing import Any, Dict, Generic, List, Optional, TypeVar, cast
88

99
import pystac
1010
from pystac.serialization.identify import STACJSONDescription, STACVersionID
@@ -344,8 +344,8 @@ def __repr__(self) -> str:
344344

345345
class SarExtensionHooks(ExtensionHooks):
346346
schema_uri = SCHEMA_URI
347-
prev_extension_ids: Set[str] = set(["sar"])
348-
stac_object_types: Set[pystac.STACObjectType] = set([pystac.STACObjectType.ITEM])
347+
prev_extension_ids = {"sar"}
348+
stac_object_types = {pystac.STACObjectType.ITEM}
349349

350350
def migrate(
351351
self, obj: Dict[str, Any], version: STACVersionID, info: STACJSONDescription

pystac/extensions/sat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import enum
77
from datetime import datetime as Datetime
88
from pystac.summaries import RangeSummary
9-
from typing import Dict, Any, List, Generic, Iterable, Optional, Set, TypeVar, cast
9+
from typing import Dict, Any, List, Iterable, Generic, Optional, TypeVar, cast
1010

1111
import pystac
1212
from pystac.extensions.base import (
@@ -292,8 +292,8 @@ def anx_datetime(self, v: Optional[RangeSummary[Datetime]]) -> None:
292292

293293
class SatExtensionHooks(ExtensionHooks):
294294
schema_uri: str = SCHEMA_URI
295-
prev_extension_ids: Set[str] = set(["sat"])
296-
stac_object_types: Set[pystac.STACObjectType] = set([pystac.STACObjectType.ITEM])
295+
prev_extension_ids = {"sat"}
296+
stac_object_types = {pystac.STACObjectType.ITEM}
297297

298298

299299
SAT_EXTENSION_HOOKS: ExtensionHooks = SatExtensionHooks()

pystac/extensions/scientific.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import copy
1111
from enum import Enum
12-
from typing import Any, Dict, Generic, List, Optional, Set, TypeVar, Union, cast
12+
from typing import Any, Dict, Generic, List, Optional, TypeVar, Union, cast
1313
from urllib import parse
1414

1515
import pystac
@@ -350,10 +350,8 @@ def doi(self, v: Optional[List[str]]) -> None:
350350

351351
class ScientificExtensionHooks(ExtensionHooks):
352352
schema_uri: str = SCHEMA_URI
353-
prev_extension_ids: Set[str] = set(["scientific"])
354-
stac_object_types: Set[pystac.STACObjectType] = set(
355-
[pystac.STACObjectType.COLLECTION, pystac.STACObjectType.ITEM]
356-
)
353+
prev_extension_ids = {"scientific"}
354+
stac_object_types = {pystac.STACObjectType.COLLECTION, pystac.STACObjectType.ITEM}
357355

358356

359357
SCIENTIFIC_EXTENSION_HOOKS: ExtensionHooks = ScientificExtensionHooks()

0 commit comments

Comments
 (0)