Skip to content

Commit

Permalink
fix flake8/ruff/lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Feb 28, 2024
1 parent 6511088 commit 4f10dad
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 24 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 8 additions & 7 deletions xscen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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"

Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions xscen/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -42,6 +41,7 @@
"ProjectCatalog",
"concat_data_catalogs",
"generate_id",
"subset_file_coverage",
"unstack_id",
]

Expand Down
11 changes: 2 additions & 9 deletions xscen/catutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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],
*,
Expand Down
9 changes: 7 additions & 2 deletions xscen/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion xscen/indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions xscen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -48,6 +51,7 @@
"unstack_dates",
"unstack_fill_nan",
"update_attr",
"xrfreq_to_timedelta",
]

TRANSLATOR = defaultdict(lambda: lambda s: s)
Expand Down

0 comments on commit 4f10dad

Please sign in to comment.