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

Example not working in VSCode #211

Open
krokosik opened this issue Aug 11, 2023 · 0 comments
Open

Example not working in VSCode #211

krokosik opened this issue Aug 11, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@krokosik
Copy link

The whole reason I'd like to use this package is to have in editor suggestions when working with Xarray. However, even the case provided in the README does not work in the current 1.6.0 version. In particular, the following code produces an error with basic type checking.

from dataclasses import dataclass
from typing import Literal
from xarray_dataclasses import AsDataArray, Coord, Data


X = Literal["x"]
Y = Literal["y"]


@dataclass
class Image(AsDataArray):
    """2D image as DataArray."""

    data: Data[tuple[X, Y], float]
    x: Coord[X, int] = 0
    y: Coord[Y, int] = 0


image = Image.new([[2.0, 2.0], [2.0, 2.0]], x=[0, 1], y=[0, 1])
Argument of type "list[list[float]]" cannot be assigned to parameter "data" of type "Data[tuple[X, Y], float]"
  "list[float]" is incompatible with "float"
  "list[float]" is incompatible with "float"Pylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)
@astropenguin astropenguin added the bug Something isn't working label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants