Skip to content

Commit

Permalink
Update type annotation and logger message
Browse files Browse the repository at this point in the history
- Update `dev.yml`
  • Loading branch information
tomvothecoder committed Nov 28, 2023
1 parent 643bd93 commit bee4c29
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
30 changes: 15 additions & 15 deletions conda-env/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ dependencies:
- shapely >=2.0.0,<3.0.0
- xarray >=2023.02.0
# Testing
# ==================
# =======================
- scipy
- pytest
- pytest-cov
# Documentation
# =================
# =======================
- sphinx
- sphinx_rtd_theme
- sphinx-multiversion
# Quality Assurance Tools
# =======================
# Run `pre-commit autoupdate` to get the latest pinned versions of 'rev' in
# `.pre-commit.config.yaml`, then update the pinned versions here.
- black=23.9.1
- flake8=6.1.0
- flake8-isort=6.1.0
- isort=5.12.0
- mypy=1.5.1
- pre-commit >=3.0.0
- types-PyYAML >=6.0.0
# Developer Tools
# =================
# If versions are updated, also update 'rev' in `.pre-commit.config.yaml`
- black=22.10.0
- flake8=6.0.0
- flake8-isort=5.0.3
- isort=5.11.3
- mypy=0.991
- pre-commit=2.20.0
- pytest=7.2.0
- pytest-cov=4.0.0
- types-PyYAML=6.0.12.6
# Developer Tools
# =================
# =======================
- tbump=6.9.0
- ipykernel
prefix: /opt/miniconda3/envs/e3sm_diags_dev
2 changes: 1 addition & 1 deletion e3sm_diags/parameter/core_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self):
# 'model_vs_obs' (by default), 'model_vs_model', or 'obs_vs_obs'.
self.run_type: str = "model_vs_obs"

# A list of the sets to be run. Default is all sets
# A list of the sets to be run.
self.sets: List[str] = []

# The current set that is being ran when looping over sets in
Expand Down
13 changes: 7 additions & 6 deletions e3sm_diags/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import copy
from itertools import chain
from typing import List
from typing import List, Union

import e3sm_diags # noqa: F401
from e3sm_diags.e3sm_diags_driver import main
Expand Down Expand Up @@ -55,7 +55,9 @@ def get_final_parameters(self, parameters):
param_types_set = set(param_types_list)

if len(param_types_set) != len(param_types_list):
msg = "You passed in two or more non-CoreParameter parameters of the same type."
msg = (
"You passed in two or more non-CoreParameter objects of the same type."
)
raise RuntimeError(msg)

self._add_parent_attrs_to_children(parameters)
Expand Down Expand Up @@ -241,12 +243,13 @@ def _get_instance_of_param_class(self, cls, parameters):
msg = "There's weren't any class of types {} in your parameters."
raise RuntimeError(msg.format(class_types))

def _get_diags_from_cfg_file(self) -> List[CoreParameter] | List:
def _get_diags_from_cfg_file(self) -> Union[List, List[CoreParameter]]:
"""Get diagnostics defined in a cfg file using ``-d`` CLI arg.
If ``-d`` is not passed, return an empty list.
"""
args = self.parser.view_args()
params = []

# If the user has passed in args with -d.
if args.other_parameters:
Expand All @@ -256,9 +259,7 @@ def _get_diags_from_cfg_file(self) -> List[CoreParameter] | List:
for i in range(len(params)):
params[i] = SET_TO_PARAMETERS[params[i].sets[0]]() + params[i]

return params

return []
return params


runner = Run()

0 comments on commit bee4c29

Please sign in to comment.