Skip to content

Commit

Permalink
DAS-2108: stop pruning datatree_ directory
Browse files Browse the repository at this point in the history
Quick fixup of some typing.
Removes mypy exclusions for datatree_
  • Loading branch information
flamingbear committed Apr 17, 2024
1 parent 9a37053 commit 84d23be
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

10 changes: 1 addition & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,14 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]

[tool.mypy]
enable_error_code = "redundant-self"
exclude = [
'xarray/util/generate_.*\.py',
'xarray/datatree_/.*\.py',
]
exclude = 'xarray/util/generate_.*\.py'
files = "xarray"
show_error_codes = true
show_error_context = true
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 84d23be

Please sign in to comment.