diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04d05140..8982cd51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,6 +29,7 @@ repos: hooks: - id: python-check-blanket-noqa - id: python-no-eval + exclude: biasadjust.py - id: python-no-log-warn - id: python-use-type-annotations - id: rst-inline-touching-normal diff --git a/docs/conf.py b/docs/conf.py index 88bb5908..3076a05c 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,13 +26,13 @@ sys.path.insert(0, os.path.abspath("..")) if os.environ.get("READTHEDOCS") and "ESMFMKFILE" not in os.environ: - # RTD doesn't activate the env, and esmpy depends on a env var set there + # RTD doesn't activate the env, and esmpy depends on an env var set there # We assume the `os` package is in {ENV}/lib/pythonX.X/os.py # See conda-forge/esmf-feedstock#91 and readthedocs/readthedocs.org#4067 os.environ["ESMFMKFILE"] = str(Path(os.__file__).parent.parent / "esmf.mk") -import xscen # noqa -import xarray # noqa +import xscen # noqa: E402,F401 +import xarray # noqa: E402 xarray.DataArray.__module__ = "xarray" xarray.Dataset.__module__ = "xarray" diff --git a/xscen/__init__.py b/xscen/__init__.py index bf2f0b5b..7e03c563 100644 --- a/xscen/__init__.py +++ b/xscen/__init__.py @@ -25,19 +25,19 @@ # Import top-level functions from .aggregate import * from .biasadjust import * -from .catalog import DataCatalog, ProjectCatalog # noqa +from .catalog import DataCatalog, ProjectCatalog from .catutils import build_path, parse_directory -from .config import CONFIG, load_config # noqa +from .config import CONFIG, load_config from .diagnostics import properties_and_measures from .ensembles import * -from .extract import ( # noqa +from .extract import ( extract_dataset, get_warming_level, search_data_catalogs, subset_warming_level, ) -from .indicators import compute_indicators # noqa -from .io import save_to_netcdf, save_to_table, save_to_zarr # noqa +from .indicators import compute_indicators +from .io import save_to_netcdf, save_to_table, save_to_zarr from .reduce import build_reduction_data, reduce_ensemble from .regrid import * from .scripting import ( @@ -58,7 +58,7 @@ def warning_on_one_line( message: str, category: Warning, filename: str, lineno: int, file=None, line=None -): # noqa: D103 +): """Monkeypatch Reformat warning so that `warnings.warn` doesn't mention itself.""" return f"{filename}:{lineno}: {category.__name__}: {message}\n" @@ -72,7 +72,8 @@ def warning_on_one_line( category=FutureWarning, module="intake_esm", message="The default of observed=False is deprecated and will be changed to True in a future version of pandas. " - "Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.", + "Pass observed=False to retain current behavior or observed=True to adopt the future default " + "and silence this warning.", ) warnings.filterwarnings( "ignore", diff --git a/xscen/catalog.py b/xscen/catalog.py index d10d3fb0..82ba671d 100644 --- a/xscen/catalog.py +++ b/xscen/catalog.py @@ -22,8 +22,7 @@ from intake_esm.cat import ESMCatalogModel from .config import CONFIG, args_as_str, recursive_update -from .utils import ( # noqa - CV, +from .utils import ( date_parser, ensure_correct_time, ensure_new_xrfreq, @@ -42,6 +41,7 @@ "ProjectCatalog", "concat_data_catalogs", "generate_id", + "subset_file_coverage", "unstack_id", ] diff --git a/xscen/catutils.py b/xscen/catutils.py index c6197571..d7b630e1 100644 --- a/xscen/catutils.py +++ b/xscen/catutils.py @@ -30,14 +30,7 @@ from .catalog import COLUMNS, DataCatalog, generate_id from .config import parse_config from .io import get_engine -from .utils import ( # noqa - CV, - date_parser, - ensure_correct_time, - ensure_new_xrfreq, - get_cat_attrs, - standardize_periods, -) +from .utils import CV, date_parser, ensure_new_xrfreq, get_cat_attrs logger = logging.getLogger(__name__) @@ -434,7 +427,7 @@ def _parse_first_ds( @parse_config -def parse_directory( # noqa:C901 +def parse_directory( # noqa: C901 directories: list[Union[str, os.PathLike]], patterns: list[str], *, diff --git a/xscen/extract.py b/xscen/extract.py index 527a4420..0a29e6ad 100644 --- a/xscen/extract.py +++ b/xscen/extract.py @@ -18,8 +18,13 @@ from intake_esm.derived import DerivedVariableRegistry from xclim.core.calendar import compare_offsets -from .catalog import DataCatalog # noqa -from .catalog import ID_COLUMNS, concat_data_catalogs, generate_id, subset_file_coverage +from .catalog import ( + ID_COLUMNS, + DataCatalog, + concat_data_catalogs, + generate_id, + subset_file_coverage, +) from .catutils import parse_from_ds from .config import parse_config from .indicators import load_xclim_module, registry_from_module diff --git a/xscen/indicators.py b/xscen/indicators.py index 02e8ff6e..68e43df5 100644 --- a/xscen/indicators.py +++ b/xscen/indicators.py @@ -21,7 +21,7 @@ logger = logging.getLogger(__name__) -__all__ = ["compute_indicators", "load_xclim_module"] +__all__ = ["compute_indicators", "load_xclim_module", "registry_from_module"] def load_xclim_module( diff --git a/xscen/utils.py b/xscen/utils.py index 4e0adad3..c629f295 100644 --- a/xscen/utils.py +++ b/xscen/utils.py @@ -33,10 +33,13 @@ logger = logging.getLogger(__name__) __all__ = [ + "CV", "add_attr", "change_units", "clean_up", "date_parser", + "ensure_correct_time", + "ensure_new_xrfreq", "get_cat_attrs", "maybe_unstack", "minimum_calendar", @@ -48,6 +51,7 @@ "unstack_dates", "unstack_fill_nan", "update_attr", + "xrfreq_to_timedelta", ] TRANSLATOR = defaultdict(lambda: lambda s: s)