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

Typing: DataTree[Unknown] #313

Closed
etienneschalk opened this issue Feb 17, 2024 · 1 comment
Closed

Typing: DataTree[Unknown] #313

etienneschalk opened this issue Feb 17, 2024 · 1 comment

Comments

@etienneschalk
Copy link
Contributor

Try to instantiate a DataTree:

root = DataTree(name="root")

VSCode with Pylance will complain:

Type of "root" is partially unknown
  Type of "root" is "DataTree[Unknown]"
Pylance[reportUnknownVariableType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUnknownVariableType)
(variable) root: DataTree[Unknown]

Going to the DataTree class definition and hovering the Mapping parent class:

Expected type arguments for generic class "Mapping"
Pylance[reportMissingTypeArgument](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingTypeArgument)
(class) Mapping

Same for NamedNode:

Expected type arguments for generic class "NamedNode"
Pylance[reportMissingTypeArgument](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingTypeArgument)
(class) NamedNode
A TreeNode which knows its own name.

Implements path-like relationships to other nodes in its tree.

If we compare to the Dataset definition in xarray:

https://github.com/pydata/xarray/blob/ff0d056ec9e99dece0202d8d73c1cb8c6c20b2a1/xarray/core/dataset.py#L511

We can see that the type parameters of Mapping are provided

@TomNicholas
Copy link
Member

This was probably closed by pydata/xarray#9445 - we can re-open upstream if not.

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

No branches or pull requests

2 participants