Skip to content

Commit

Permalink
Update mypy and fix new type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Jan 8, 2022
1 parent aff094a commit 366bacb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion environment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- isort
- make
- mdformat
- mypy = 0.812
- mypy
- netcdf4
- nomkl
- numpy >= 1.22.0
Expand All @@ -17,6 +17,7 @@ dependencies:
- pytest-cov
- rasterio >= 1.2.4
- rioxarray
- types-setuptools
- xarray >= 0.20.2
- xmlschema
- zarr
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import setuptools # type: ignore
import setuptools

setuptools.setup(use_scm_version={"fallback_version": "999"})
7 changes: 2 additions & 5 deletions xarray_sentinel/esa_safe.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,13 @@ def cached_sentinel1_schemas(schema_type: str) -> xmlschema.XMLSchema:
return xmlschema.XMLSchema(SENTINEL1_SCHEMAS[schema_type])


cached_ElementTree_parse = functools.lru_cache(ElementTree.parse)


def parse_tag(
xml_path: PathOrFileType,
query: str,
schema_type: str = "annotation",
) -> T.Dict[str, T.Any]:
schema = cached_sentinel1_schemas(schema_type)
xml_tree = cached_ElementTree_parse(xml_path)
xml_tree = ElementTree.parse(xml_path)
tag_dict: T.Dict[str, T.Any] = schema.to_dict(xml_tree, query) # type: ignore
assert isinstance(tag_dict, dict)
return tag_dict
Expand All @@ -73,7 +70,7 @@ def parse_tag_list(
schema_type: str = "annotation",
) -> T.List[T.Dict[str, T.Any]]:
schema = cached_sentinel1_schemas(schema_type)
xml_tree = cached_ElementTree_parse(xml_path)
xml_tree = ElementTree.parse(xml_path)
tag_list: T.List[T.Dict[str, T.Any]] = schema.to_dict(xml_tree, query) # type: ignore
assert isinstance(tag_list, list)
return tag_list
Expand Down

0 comments on commit 366bacb

Please sign in to comment.