diff --git a/.gitmodules b/.gitmodules index 9f16caae..f7a49695 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,9 +5,9 @@ branch = develop [submodule "pyFV3"] path = pyFV3 - url = https://github.com/NOAA-GFDL/PyFV3.git + url = https://github.com/NOAA-GFDL/pyFV3.git branch = develop [submodule "pySHiELD"] path = pySHiELD - url = https://github.com/NOAA-GFDL/PySHiELD.git + url = https://github.com/NOAA-GFDL/pySHiELD.git branch = develop diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c022eb48..020150f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: repos: - repo: https://github.com/psf/black - rev: 25.1.0 + rev: 25.9.0 hooks: - id: black @@ -14,16 +14,16 @@ repos: args: ["--profile", "black"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.17.0 + rev: v1.18.2 hooks: - id: mypy - additional_dependencies: [types-pyyaml] + additional_dependencies: [types-PyYAML] name: mypy-pace files: pace args: ["--config-file", "pyproject.toml"] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-toml - id: check-yaml @@ -36,7 +36,7 @@ repos: - id: flake8 name: flake8 language_version: python3 - additional_dependencies: [Flake8-pyproject] + additional_dependencies: [Flake8-pyproject, flake8-bugbear] - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks rev: v2.15.0 diff --git a/NDSL b/NDSL index 2430f879..ada2d537 160000 --- a/NDSL +++ b/NDSL @@ -1 +1 @@ -Subproject commit 2430f879bb996e4ff301ecd1d9bf72804fb0e4c4 +Subproject commit ada2d5379540aba26681b2a1ea2588dd6895fc48 diff --git a/pace/diagnostics.py b/pace/diagnostics.py index 5a4b9d54..d2c128b1 100644 --- a/pace/diagnostics.py +++ b/pace/diagnostics.py @@ -197,7 +197,9 @@ def _get_derived_state(self, state: DriverState): state.dycore_state.delp, ) else: - warnings.warn(f"{name} is not a supported diagnostic variable.") + warnings.warn( + f"{name} is not a supported diagnostic variable.", stacklevel=2 + ) return output def _get_z_select_state(self, state: DycoreState): diff --git a/pace/driver.py b/pace/driver.py index f6f825d8..1bcb3ed2 100644 --- a/pace/driver.py +++ b/pace/driver.py @@ -150,7 +150,8 @@ def n_timesteps(self) -> int: if self.total_time < self.timestep: warnings.warn( f"No simulation possible: you asked for {self.total_time} " - f"simulation time but the timestep is {self.timestep}" + f"simulation time but the timestep is {self.timestep}", + stacklevel=2, ) return floor(self.total_time.total_seconds() / self.timestep.total_seconds()) @@ -442,7 +443,7 @@ def exit_function(*args, **kwargs): ) exit(0) - setattr(self, "step_all", exit_function) + self.step_all = exit_function # type: ignore[method-assign] elif self.config.stencil_config.compilation_config.run_mode == RunMode.Run: def exit_instead_of_build(self): @@ -457,7 +458,7 @@ def exit_instead_of_build(self): from gt4py.stencil_builder import StencilBuilder - setattr(StencilBuilder, "build", exit_instead_of_build) + StencilBuilder.build = exit_instead_of_build # type: ignore["method-assign"] self.config.stencil_config.dace_config = DaceConfig( communicator=communicator, diff --git a/pace/initialization.py b/pace/initialization.py index eaab682d..36377c16 100644 --- a/pace/initialization.py +++ b/pace/initialization.py @@ -91,7 +91,9 @@ def get_driver_state( ) @classmethod - def from_dict(cls, config: dict, hooks={}): + def from_dict(cls, config: dict, hooks: dict | None = None): + if not hooks: + hooks = {} instance = cls.registry.from_dict(config, hooks=hooks) return cls(config=instance, type=config["type"]) diff --git a/pace/registry.py b/pace/registry.py index 49849386..ac1b53c7 100644 --- a/pace/registry.py +++ b/pace/registry.py @@ -105,7 +105,7 @@ def register_func(cls: TT) -> TT: return register_func - def from_dict(self, config: dict, hooks={}) -> T: + def from_dict(self, config: dict, hooks: dict | None = None) -> T: """ Creates a registered type from the given config dict. @@ -116,6 +116,8 @@ def from_dict(self, config: dict, hooks={}) -> T: It can also have a "config" key, which is a dict used to initialize the dataclass. By default this is an empty dict. """ + if not hooks: + hooks = {} config.setdefault("config", {}) if self.default_type is not None: type_name = config.get("type", self.default_type) diff --git a/pyFV3 b/pyFV3 index 731933a1..20b00071 160000 --- a/pyFV3 +++ b/pyFV3 @@ -1 +1 @@ -Subproject commit 731933a1b971392e58a574c6d34c7d893888899b +Subproject commit 20b00071263506d4f45dedf3ab538b501f400103 diff --git a/pySHiELD b/pySHiELD index 80558ac3..49edb676 160000 --- a/pySHiELD +++ b/pySHiELD @@ -1 +1 @@ -Subproject commit 80558ac38417e313aab1e241b5a0e0eb66f1b135 +Subproject commit 49edb676674407c6b9c1795807d4c86d27acb69e diff --git a/pyproject.toml b/pyproject.toml index fc4d0617..8fe8cf67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ warn_unreachable = true ignore_errors = true module = [ # We currently can't type stencils + "pyfv3.stencils.*", "pyshield.stencils.*" ] diff --git a/tests/main/fv3core/test_config.py b/tests/main/fv3core/test_config.py index 5bddc03f..663778f8 100644 --- a/tests/main/fv3core/test_config.py +++ b/tests/main/fv3core/test_config.py @@ -41,7 +41,7 @@ def value(self) -> int: def assert_types_match(classes): types = collections.defaultdict(set) for cls in classes: - for name, field in cls.__dataclass_fields__.items(): + for name, _field in cls.__dataclass_fields__.items(): # Get type hints in case we're using postponed evaluation of types # Example: ' instead of 'bool' types[name].add(typing.get_type_hints(cls)[name])