Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pace/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 4 additions & 3 deletions pace/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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):
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion pace/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
4 changes: 3 additions & 1 deletion pace/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pySHiELD
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ warn_unreachable = true
ignore_errors = true
module = [
# We currently can't type stencils
"pyfv3.stencils.*",
"pyshield.stencils.*"
]

Expand Down
2 changes: 1 addition & 1 deletion tests/main/fv3core/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<class 'bool'> instead of 'bool'
types[name].add(typing.get_type_hints(cls)[name])
Expand Down