Skip to content

Commit f2063d5

Browse files
committed
Enabled ANN ruleset and fixed violations
1 parent fea3e05 commit f2063d5

12 files changed

Lines changed: 30 additions & 35 deletions

File tree

earthaccess/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
import threading
3-
from typing import Optional
3+
from typing import Optional, Any
44

55
from .api import (
66
auth_environ,
@@ -76,7 +76,7 @@
7676
_lock = threading.Lock()
7777

7878

79-
def __getattr__(name): # type: ignore
79+
def __getattr__(name: str): # noqa: ANN202
8080
"""Module-level getattr to handle automatic authentication when accessing
8181
`earthaccess.__auth__` and `earthaccess.__store__`.
8282

earthaccess/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def _normalize_location(location: str | None) -> str | None:
8888
return location
8989

9090

91-
def search_datasets(count: int = -1, **kwargs: Any) -> list[DataCollection]:
91+
def search_datasets(count: int = -1, **kwargs: Any) -> list[DataCollection]: # noqa: ANN401
9292
"""Search datasets (collections) using NASA's CMR.
9393
9494
[https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html](https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html)
@@ -186,7 +186,7 @@ def search_datasets(count: int = -1, **kwargs: Any) -> list[DataCollection]:
186186
return query.get_all()
187187

188188

189-
def search_data(count: int = -1, **kwargs: Any) -> list[DataGranule]:
189+
def search_data(count: int = -1, **kwargs: Any) -> list[DataGranule]: # noqa: ANN401
190190
"""Search for dataset files (granules) using NASA's CMR.
191191
192192
[https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html](https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html)
@@ -280,7 +280,7 @@ def search_data(count: int = -1, **kwargs: Any) -> list[DataGranule]:
280280
return query.get_all()
281281

282282

283-
def search_services(count: int = -1, **kwargs: Any) -> list[Any]:
283+
def search_services(count: int = -1, **kwargs: Any) -> list[Any]: # noqa: ANN401
284284
"""Search the NASA CMR for Services matching criteria.
285285
286286
See <https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html#service>.

earthaccess/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(self, hostname: str, auth: tuple[str, str]) -> None:
5757
self.hostname = hostname
5858
self.auth = auth
5959

60-
def __call__(self, r: requests.Response, **kwargs: Any) -> requests.Response:
60+
def __call__(self, r: requests.Response, **kwargs: Any) -> requests.Response: # noqa: ANN401
6161

6262
# If the response's URL is not for the EDL system we're authenticating
6363
# against, then simply return the response unchanged. Otherwise, we'll
@@ -113,7 +113,7 @@ def login(
113113
strategy: str = "netrc",
114114
persist: bool = False, # noqa: FBT001, FBT002
115115
system: System | None = None,
116-
) -> Any:
116+
) -> Any: # noqa: ANN401
117117
"""Authenticate with Earthdata login.
118118
119119
Parameters:

earthaccess/formatters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _repr_collection_html() -> str:
1818
return "<div></div>"
1919

2020

21-
def _repr_granule_html(granule: Any) -> str:
21+
def _repr_granule_html(granule: Any) -> str: # noqa: ANN401
2222
css_styles = _load_static_files()
2323
css_inline = f"""<div id="{uuid4()}" style="height: 0px; display: none">
2424
{"".join([f"<style>{style}</style>" for style in css_styles])}

earthaccess/results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(
3131
collection: dict[str, Any],
3232
fields: list[str] | None = None,
3333
cloud_hosted: bool = False, # noqa: FBT001, FBT002
34-
):
34+
) -> None:
3535
super().__init__(collection)
3636
self.cloud_hosted = cloud_hosted
3737
self.uuid = str(uuid.uuid4())
@@ -341,7 +341,7 @@ def __init__(
341341
collection: dict[str, Any],
342342
fields: list[str] | None = None,
343343
cloud_hosted: bool = False, # noqa: FBT001, FBT002
344-
):
344+
) -> None:
345345
super().__init__(collection)
346346
self.cloud_hosted = cloud_hosted
347347
# TODO: maybe add area, start date and all that as an instance value

earthaccess/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DataCollections(CollectionQuery):
3636
_fields: list[str] | None = None
3737
_format = "umm_json"
3838

39-
def __init__(self, auth: Auth | None = None, *args: Any, **kwargs: Any) -> None:
39+
def __init__(self, auth: Auth | None = None, *args: Any, **kwargs: Any) -> None: # noqa: ANN401
4040
"""Builds an instance of DataCollections to query the CMR.
4141
4242
Parameters:
@@ -426,7 +426,7 @@ class DataGranules(GranuleQuery):
426426

427427
_format = "umm_json"
428428

429-
def __init__(self, auth: Auth | None = None, *args: Any, **kwargs: Any) -> None:
429+
def __init__(self, auth: Auth | None = None, *args: Any, **kwargs: Any) -> None: # noqa: ANN401
430430
super().__init__(*args, **kwargs)
431431

432432
self.session = (
@@ -749,7 +749,7 @@ def _valid_state(self) -> bool:
749749
key in self.params for key in collection_keys
750750
)
751751

752-
def _is_cloud_hosted(self, granule: Any) -> bool:
752+
def _is_cloud_hosted(self, granule: Any) -> bool: # noqa: ANN401
753753
"""Check if a granule record, from CMR, advertises "direct access"."""
754754
if "RelatedUrls" not in granule["umm"]:
755755
return False

earthaccess/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DataServices(ServiceQuery):
1616

1717
_format = "umm_json"
1818

19-
def __init__(self, auth: Auth | None = None, *args: Any, **kwargs: Any) -> None:
19+
def __init__(self, auth: Auth | None = None, *args: Any, **kwargs: Any) -> None: # noqa: ANN401
2020
"""Build an instance of DataService to query CMR.
2121
2222
auth is an optional parameter for queries that need authentication,

earthaccess/store.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(
8585
self.f = f
8686
self.granule = granule
8787

88-
def __getattribute__(self, name: str) -> Any:
88+
def __getattribute__(self, name: str) -> Any: # noqa: ANN401
8989
# use super().__getattribute__ to avoid infinite recursion
9090
if (name in EarthAccessFile.__dict__) or (name in self.__dict__):
9191
# accessing our attributes
@@ -94,7 +94,7 @@ def __getattribute__(self, name: str) -> Any:
9494
proxy = super().__getattribute__("f")
9595
return getattr(proxy, name)
9696

97-
def __reduce_ex__(self, protocol: Any) -> Any:
97+
def __reduce_ex__(self, protocol: Any) -> Any: # noqa: ANN401
9898
return make_instance, (
9999
self.__class__,
100100
self.granule,
@@ -163,10 +163,10 @@ def multi_thread_open(data: tuple[str, DataGranule | None]) -> EarthAccessFile:
163163

164164

165165
def make_instance(
166-
cls: Any,
166+
cls: Any, # noqa: ANN401
167167
granule: DataGranule,
168168
auth: Auth,
169-
data: Any,
169+
data: Any, # noqa: ANN401
170170
) -> EarthAccessFile:
171171
# Attempt to re-authenticate
172172
if not earthaccess.__auth__.authenticated:
@@ -236,7 +236,7 @@ def _sibling_tempfile(sibling: Path) -> Generator[Path, None, None]:
236236
class Store:
237237
"""Store class to access granules on-prem or in the cloud."""
238238

239-
def __init__(self, auth: Any, pre_authorize: bool = False) -> None: # noqa: FBT001, FBT002
239+
def __init__(self, auth: Any, pre_authorize: bool = False) -> None: # noqa: FBT001, FBT002, ANN401
240240
"""Store is the class to access data.
241241
242242
Parameters:

earthaccess/utils/_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Any
22

33

4-
def valid_dataset_parameters(**kwargs: Any) -> bool:
4+
def valid_dataset_parameters(**kwargs: Any) -> bool: # noqa: ANN401
55
return len(kwargs) != 0

earthaccess/virtual/_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
def resolve_parser(
4444
parser: ParserType,
4545
group: str | None = None,
46-
) -> Any:
46+
) -> Any: # noqa: ANN401
4747
"""Resolve a parser name or instance to a VirtualiZarr parser object.
4848
4949
If ``parser`` is already an instance (i.e. not a ``str``) it is returned
@@ -106,7 +106,7 @@ def resolve_parser(
106106

107107
def get_urls_for_parser(
108108
granules: list[earthaccess.DataGranule],
109-
parser: Any,
109+
parser: Any, # noqa: ANN401
110110
access: AccessType,
111111
) -> list[str]:
112112
"""Return one data URL per granule, formatted for the given parser.

0 commit comments

Comments
 (0)