Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add Typing #301

Open
mgorfer opened this issue Sep 8, 2023 · 4 comments
Open

Feature Request: Add Typing #301

mgorfer opened this issue Sep 8, 2023 · 4 comments

Comments

@mgorfer
Copy link

mgorfer commented Sep 8, 2023

I would be interested to see correct typing hints when using xESMF.

For my small function, I am getting an error at the return

def regrid_to_lat_lon(
    ds: xr.Dataset,
    target_res_lat: float = 1,
    target_res_lon: float = 1,
) -> xr.Dataset:
    ds_out = xe.util.grid_global(target_res_lat, target_res_lon, cf=True)
    regridder = xe.Regridder(
        ds,
        ds_out,
        "bilinear",
        periodic=True,
    )
    dr_out = regridder(ds, keep_attrs=True)
    return dr_out
Expression of type "NDArray[Any] | Any" cannot be assigned to return type "Dataset"
  Type "NDArray[Any] | Any" cannot be assigned to type "Dataset"
    "NDArray[Any]" is incompatible with "Dataset"Pylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)

There are probably not a lot of functions or classes which need typing hints for the average user.
I would also be interested to open a Pull Request for this, if the developers want it.

@huard
Copy link
Contributor

huard commented Sep 11, 2023

@mgorfer,

We'll gladly review and merge a PR for this!

Thanks,

@Siddhesh-Agarwal
Copy link

@huard Has this been solved? if not, can I take it?

@mgorfer
Copy link
Author

mgorfer commented Oct 11, 2023

@Siddhesh-Agarwal
I did not start this project yet. I would be glad if you could take over.

@Siddhesh-Agarwal
Copy link

Hey @huard @mgorfer I think this does the job. Can anyone review the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants