Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants