Skip to content

Commit

Permalink
stop pruning datatree_ directory from distribution (#8953)
Browse files Browse the repository at this point in the history
* DAS-2108: stop pruning datatree_ directory

Quick fixup of some typing.
Removes mypy exclusions for datatree_

* Include only code files in distribution package.

* Update pyproject.toml

exclude docs from mypy tests

Co-authored-by: Justus Magin <keewis@users.noreply.github.com>

* Update MANIFEST.in

try again to include just code from datatree_

Co-authored-by: Justus Magin <keewis@users.noreply.github.com>

---------

Co-authored-by: Justus Magin <keewis@users.noreply.github.com>
  • Loading branch information
flamingbear and keewis committed Apr 23, 2024
1 parent 5a35ca4 commit b003674
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
prune xarray/datatree_*
recursive-include xarray/datatree_/datatree *.py
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]
enable_error_code = "redundant-self"
exclude = [
'xarray/util/generate_.*\.py',
'xarray/datatree_/.*\.py',
'xarray/datatree_/doc/.*\.py',
]
files = "xarray"
show_error_codes = true
Expand All @@ -97,11 +97,6 @@ warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true

# Ignore mypy errors for modules imported from datatree_.
[[tool.mypy.overrides]]
ignore_errors = true
module = "xarray.datatree_.*"

# Much of the numerical computing stack doesn't have type annotations yet.
[[tool.mypy.overrides]]
ignore_missing_imports = true
Expand Down
10 changes: 5 additions & 5 deletions xarray/datatree_/datatree/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

def _get_nc_dataset_class(engine):
if engine == "netcdf4":
from netCDF4 import Dataset # type: ignore
from netCDF4 import Dataset
elif engine == "h5netcdf":
from h5netcdf.legacyapi import Dataset # type: ignore
from h5netcdf.legacyapi import Dataset
elif engine is None:
try:
from netCDF4 import Dataset
except ImportError:
from h5netcdf.legacyapi import Dataset # type: ignore
from h5netcdf.legacyapi import Dataset
else:
raise ValueError(f"unsupported engine: {engine}")
return Dataset
Expand Down Expand Up @@ -78,7 +78,7 @@ def _datatree_to_netcdf(


def _create_empty_zarr_group(store, group, mode):
import zarr # type: ignore
import zarr

root = zarr.open_group(store, mode=mode)
root.create_group(group, overwrite=True)
Expand All @@ -92,7 +92,7 @@ def _datatree_to_zarr(
consolidated: bool = True,
**kwargs,
):
from zarr.convenience import consolidate_metadata # type: ignore
from zarr.convenience import consolidate_metadata

if kwargs.get("group", None) is not None:
raise NotImplementedError(
Expand Down
11 changes: 5 additions & 6 deletions xarray/datatree_/datatree/tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ def foo(self):
return "bar"

dt: DataTree = DataTree()
assert dt.demo.foo == "bar" # type: ignore
assert dt.demo.foo == "bar"

# accessor is cached
assert dt.demo is dt.demo # type: ignore
assert dt.demo is dt.demo

# check descriptor
assert dt.demo.__doc__ == "Demo accessor." # type: ignore
# TODO: typing doesn't seem to work with accessors
assert DataTree.demo.__doc__ == "Demo accessor." # type: ignore
assert isinstance(dt.demo, DemoAccessor) # type: ignore
assert dt.demo.__doc__ == "Demo accessor."
assert DataTree.demo.__doc__ == "Demo accessor." # type: ignore
assert isinstance(dt.demo, DemoAccessor)
assert DataTree.demo is DemoAccessor # type: ignore

with pytest.warns(Warning, match="overriding a preexisting attribute"):
Expand Down
6 changes: 3 additions & 3 deletions xarray/datatree_/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import os
import sys

import sphinx_autosummary_accessors
import sphinx_autosummary_accessors # type: ignore

import datatree
import datatree # type: ignore

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -286,7 +286,7 @@

# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
latex_elements: dict = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
Expand Down

0 comments on commit b003674

Please sign in to comment.