Skip to content

Commit 8af3b4a

Browse files
committed
Add stubs package
1 parent 09ca776 commit 8af3b4a

6 files changed

Lines changed: 75 additions & 0 deletions

File tree

stubs-package/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# xarray_plotly_stubs
2+
3+
Type stubs for [xarray_plotly](https://github.com/felix/xarray_plotly).
4+
5+
## Installation
6+
7+
```bash
8+
pip install xarray_plotly_stubs
9+
```
10+
11+
This package provides type hints for the `da.plotly` accessor added by xarray_plotly.
12+
13+
## Usage
14+
15+
After installing, type checkers will recognize the `plotly` accessor on xarray DataArrays:
16+
17+
```python
18+
import xarray as xr
19+
import xarray_plotly # registers the accessor
20+
21+
da = xr.DataArray(...)
22+
fig = da.plotly.line() # Now properly typed!
23+
```
24+
25+
## Note
26+
27+
Install this package alongside `xarray_plotly` for full type checking support.

stubs-package/pyproject.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[project]
2+
name = "xarray_plotly_stubs"
3+
version = "0.0.1"
4+
description = "Type stubs for xarray_plotly"
5+
readme = "README.md"
6+
license = { text = "MIT" }
7+
requires-python = ">=3.10"
8+
authors = [{ name = "Felix" }]
9+
keywords = ["xarray", "plotly", "stubs", "typing"]
10+
classifiers = [
11+
"Development Status :: 3 - Alpha",
12+
"Intended Audience :: Developers",
13+
"License :: OSI Approved :: MIT License",
14+
"Programming Language :: Python :: 3",
15+
"Typing :: Stubs Only",
16+
]
17+
dependencies = [
18+
"xarray_plotly",
19+
]
20+
21+
[project.urls]
22+
Homepage = "https://github.com/felix/xarray_plotly"
23+
Repository = "https://github.com/felix/xarray_plotly"
24+
25+
[build-system]
26+
requires = ["setuptools>=61.0.0", "wheel"]
27+
build-backend = "setuptools.build_meta"
28+
29+
[tool.setuptools.packages.find]
30+
include = ["xarray_plotly_stubs*", "xarray-stubs*"]
31+
32+
[tool.setuptools.package-data]
33+
"*" = ["*.pyi", "py.typed"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Partial type stubs for xarray - adds plotly accessor to DataArray."""
2+
3+
from typing import Any
4+
5+
from xarray_plotly.accessor import DataArrayPlotlyAccessor
6+
7+
# Re-export everything from xarray
8+
from xarray import *
9+
10+
# Augment DataArray with the plotly accessor
11+
class DataArray(DataArray):
12+
@property
13+
def plotly(self) -> DataArrayPlotlyAccessor: ...
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
partial
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Type stubs for xarray_plotly."""

stubs-package/xarray_plotly_stubs/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)