html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/pull/7120#issuecomment-1267351277,https://api.github.com/repos/pydata/xarray/issues/7120,1267351277,IC_kwDOAMm_X85Lij7t,73678798,2022-10-04T17:49:39Z,2022-10-04T17:50:16Z,CONTRIBUTOR,"Thanks @max-sixty
> Here's a fix of the type checker and a small suggestion (feel free to accept or reject!)
>
> ```diff
> commit 5dad26e19f1fb22e9a31854bac9471c5e1bec43c
> Author: Maximilian Roos
> Date: Tue Oct 4 00:26:48 2022 -0700
>
> Ignore type on intentional error; (optional) tweak to error message
>
> diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py
> index ff54bd84..a3f26d26 100644
> --- a/xarray/core/dataset.py
> +++ b/xarray/core/dataset.py
> @@ -5405,7 +5405,7 @@ def transpose(
> if (len(dims) > 0) and (isinstance(dims[0], list)):
> list_fix = [f""'{x}'"" if isinstance(x, str) else f""{x}"" for x in dims[0]]
> raise TypeError(
> - f'transpose requires dims to be passed as multiple arguments. Expected ""{"", "".join(list_fix)}"". Received ""{dims[0]}"" instead'
> + f'transpose requires dims to be passed as multiple arguments. Expected `.transpose({"", "".join(list_fix)})`. Received `.transpose({dims[0]})` instead'
> )
>```
This is what I initially had but I thought it might be confusing for users passing something to missing_dims
>```diff
>
> -def test_traspose_error() -> None:
> +def test_transpose_error() -> None:
> # Transpose dataset with list as argument
> # Should raise error
> ds = xr.Dataset({""foo"": ((""x"", ""y""), [[21]]), ""bar"": ((""x"", ""y""), [[12]])})
> @@ -6817,7 +6817,7 @@ def test_traspose_error() -> None:
> with pytest.raises(
> TypeError,
> match=re.escape(
> - ""transpose requires dims to be passed as multiple arguments. Expected \""'y', 'x'\"". Received \""['y', 'x']\"" instead""
> + ""transpose requires dims to be passed as multiple arguments. Expected `.transpose('y', 'x')`. Received `.transpose(['y', 'x'])` instead""
> ),
> ):
> - ds.transpose([""y"", ""x""])
> + ds.transpose([""y"", ""x""]) # type: ignore
> ```
This is very helpful thank you!
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1395478084