Skip to content

Commit

Permalink
Disable type checks for invalid method signatures.
Browse files Browse the repository at this point in the history
These methods have a slightly wrong signature and cause pytype error when upgrading to a newer version of Xarray:
```
File "third_party/py/xee/ext.py", line 822, in EarthEngineBackendEntrypoint: Overriding method signature mismatch [signature-mismatch]
  Base signature: 'def xarray.backends.common.BackendEntrypoint.guess_can_open(self, filename_or_obj: Union[str, xarray.backends.common.AbstractDataStore, io.BufferedIOBase, os.PathLike[Any]]) -> bool'.
  Subclass signature: 'def EarthEngineBackendEntrypoint.guess_can_open(self, filename_or_obj: Union[str, os.PathLike[Any], ee.ImageCollection]) -> bool'.
  Type mismatch for parameter 'filename_or_obj'.
File "third_party/py/xee/ext.py", line 836, in EarthEngineBackendEntrypoint: Overriding method signature mismatch [signature-mismatch]
  Base signature: 'def xarray.backends.common.BackendEntrypoint.open_dataset(self, filename_or_obj: Union[str, xarray.backends.common.AbstractDataStore, io.BufferedIOBase, os.PathLike[Any]], *, drop_variables: Optional[Union[str, Iterable[str]]] = ..., **kwargs: Dict[Any, Any]) -> xarray.core.dataset.Dataset'.
  Subclass signature: 'def EarthEngineBackendEntrypoint.open_dataset(self, filename_or_obj: Union[str, os.PathLike[Any], ee.ImageCollection], drop_variables: Optional[Tuple[str, ...]] = None, io_chunks: Optional[Any] = None, n_images: int = -1, mask_and_scale: bool = True, decode_times: bool = True, decode_timedelta: Optional[bool] = None, use_cftime: Optional[bool] = None, concat_characters: bool = True, decode_coords: bool = True, crs: Optional[str] = None, scale: Optional[Union[float, int]] = None, projection: Optional[Any] = None, geometry: Optional[ee.Geometry] = None, primary_dim_name: Optional[str] = None, primary_dim_property: Optional[str] = None, ee_mask_value: Optional[float] = None, request_byte_limit: int = ...) -> xarray.core.dataset.Dataset'.
  Type mismatch for parameter 'filename_or_obj'.
```

There may be a better long-term fix, but disabling pytype is a simple way to keep this working for now.

PiperOrigin-RevId: 585312303
  • Loading branch information
shoyer authored and Xee authors committed Nov 25, 2023
1 parent 390ec0d commit af1f485
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xee/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ def _parse(self, filename_or_obj: Union[str, os.PathLike[Any]]) -> str:

def guess_can_open(
self, filename_or_obj: Union[str, os.PathLike[Any], ee.ImageCollection]
) -> bool:
) -> bool: # type: ignore
"""Returns True if the candidate is a valid ImageCollection."""
if isinstance(filename_or_obj, ee.ImageCollection):
return True
Expand Down Expand Up @@ -853,7 +853,7 @@ def open_dataset(
primary_dim_property: Optional[str] = None,
ee_mask_value: Optional[float] = None,
request_byte_limit: int = REQUEST_BYTE_LIMIT,
) -> xarray.Dataset:
) -> xarray.Dataset: # type: ignore
"""Open an Earth Engine ImageCollection as an Xarray Dataset.
Args:
Expand Down

0 comments on commit af1f485

Please sign in to comment.