Skip to content

Commit d566db8

Browse files
authored
Update pre-commit dependencies (#627)
* Update pre-commit dependencies * Update pre-commit deps in `conda/dev.yml` * Fix `black` formatting errors * Fix `flake8` programming errors
1 parent 21d75c3 commit d566db8

File tree

8 files changed

+62
-39
lines changed

8 files changed

+62
-39
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fail_fast: true
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.3.0
7+
rev: v5.0.0
88
hooks:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
@@ -13,29 +13,34 @@ repos:
1313

1414
# Can run individually with `pre-commit run black --all-files`
1515
- repo: https://github.com/psf/black
16-
rev: 22.8.0
16+
rev: 24.10.0
1717
hooks:
1818
- id: black
1919

2020
# Can run individually with `pre-commit run isort --all-files`
2121
- repo: https://github.com/PyCQA/isort
22-
rev: 5.12.0
22+
rev: 5.13.2
2323
hooks:
2424
- id: isort
2525

2626
# Can run individually with `pre-commit run flake8 --all-files`
2727
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
2828
# https://github.com/pre-commit/pre-commit/issues/1206
2929
- repo: https://github.com/pycqa/flake8
30-
rev: 5.0.4
30+
rev: 7.1.1
3131
hooks:
3232
- id: flake8
3333
args: ["--config=setup.cfg"]
34-
additional_dependencies: [flake8-isort]
34+
additional_dependencies: [flake8-isort==6.1.1]
3535

3636
# Can run individually with `pre-commit run mypy --all-files`
3737
- repo: https://github.com/pre-commit/mirrors-mypy
38-
rev: v0.982
38+
rev: v1.11.2
3939
hooks:
4040
- id: mypy
4141
args: ["--config=setup.cfg"]
42+
43+
# https://pre-commit.ci/#configuration
44+
ci:
45+
autofix_prs: false
46+
autoupdate_schedule: monthly

conda/dev.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ dependencies:
1515
# Developer Tools
1616
# =================
1717
# If versions are updated, also update 'rev' in `.pre-commit-config.yaml`
18-
- black=22.8.0 # version from https://anaconda.org/conda-forge/black
19-
- flake8=5.0.4 # version from https://anaconda.org/conda-forge/flake8
18+
- black=24.10.0 # version from https://anaconda.org/conda-forge/black
19+
- flake8=7.1.1 # version from https://anaconda.org/conda-forge/flake8
2020
# This line also implicitly installs isort
21-
- flake8-isort=4.2.0 # version from https://anaconda.org/conda-forge/flake8-isort
22-
- mypy=0.982 # version from https://anaconda.org/conda-forge/mypy
23-
- pre-commit=2.20.0 # version from https://anaconda.org/conda-forge/pre-commit
21+
- flake8-isort=6.1.1 # version from https://anaconda.org/conda-forge/flake8-isort
22+
- mypy=1.11.2 # version from https://anaconda.org/conda-forge/mypy
23+
- pre-commit=4.0.1 # version from https://anaconda.org/conda-forge/pre-commit
2424
- tbump=6.9.0
2525
# Documentation
2626
# If versions are updated, also update in `.github/workflows/build_workflow.yml`

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
def package_files(directory, prefixes, extensions):
88
"""based on https://stackoverflow.com/a/36693250/7728169"""
99
paths = []
10-
for (path, directories, filenames) in os.walk(directory):
10+
for path, directories, filenames in os.walk(directory):
1111
for filename in filenames:
1212
parts = filename.split(".")
1313
prefix = parts[0]

tests/test_sections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def compare(tester, actual, expected):
2121
tester.assertEqual(only_in_expected, set())
2222
incorrect_values = []
2323
for key in actual_keys:
24-
if type(actual[key]) == Section:
24+
if isinstance(actual[key], Section):
2525
print("Calling `compare` again on {}".format(key))
2626
compare(tester, actual[key], expected[key])
2727
elif actual[key] != expected[key]:

zppy/e3sm_diags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ def check_and_define_parameters(c: Dict[str, Any]) -> None:
200200
if ("tc_analysis" in c["sets"]) and (c["reference_data_path_tc"] == ""):
201201
# We have to guess parameters here,
202202
# because multiple year sets are defined in a single subtask.
203-
c[
204-
"reference_data_path_tc"
205-
] = f"{reference_data_path}/atm/tc-analysis_{c['ref_year1']}_{c['ref_year2']}"
203+
c["reference_data_path_tc"] = (
204+
f"{reference_data_path}/atm/tc-analysis_{c['ref_year1']}_{c['ref_year2']}"
205+
)
206206
if set(["enso_diags", "qbo", "area_mean_time_series"]) & set(c["sets"]):
207207
define_or_guess2(
208208
c,

zppy/mpas_analysis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def mpas_analysis(config: ConfigObj, script_dir: str, existing_bundles, job_ids_
6060
if ("last_year" in c.keys()) and (c["enso_year2"] > c["last_year"]):
6161
continue # Skip this year set
6262
c["scriptDir"] = script_dir
63-
prefix_suffix: str = f"_ts_{c['ts_year1']:04d}-{c['ts_year2']:04d}_climo_{c['climo_year1']:04d}-{c['climo_year2']:04d}"
63+
prefix_suffix: str = (
64+
f"_ts_{c['ts_year1']:04d}-{c['ts_year2']:04d}_climo_{c['climo_year1']:04d}-{c['climo_year2']:04d}"
65+
)
6466
prefix: str
6567
if c["subsection"]:
6668
prefix = f"mpas_analysis_{c['subsection']}{prefix_suffix}"

zppy/templates/coupled_global.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def get_ylim(standard_range, extreme_values):
156156
# -----------------------------------------------------------------------------
157157
# Plotting functions
158158

159+
159160
# 1
160161
def plot_net_toa_flux_restom(ax, xlim, exps, rgn):
161162
print("Plot 1: plot_net_toa_flux_restom")
@@ -748,24 +749,36 @@ def run(parameters, rgn): # noqa: C901
748749
use_ocn = plots_ocn or (not atmosphere_only and has_original_ocn_plots)
749750
exps: List[Dict[str, Any]] = [
750751
{
751-
"atmos": f"{case_dir}/post/atm/glb/ts/monthly/{ts_num_years}yr/"
752-
if use_atmos
753-
else None,
754-
"ice": f"{case_dir}/post/ice/glb/ts/monthly/{ts_num_years}yr/"
755-
if plots_ice
756-
else None,
757-
"land": f"{case_dir}/post/lnd/glb/ts/monthly/{ts_num_years}yr/"
758-
if plots_lnd
759-
else None,
760-
"ocean": f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
761-
if use_ocn
762-
else None,
763-
"moc": f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
764-
if use_ocn
765-
else None,
766-
"vol": f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
767-
if use_ocn
768-
else None,
752+
"atmos": (
753+
f"{case_dir}/post/atm/glb/ts/monthly/{ts_num_years}yr/"
754+
if use_atmos
755+
else None
756+
),
757+
"ice": (
758+
f"{case_dir}/post/ice/glb/ts/monthly/{ts_num_years}yr/"
759+
if plots_ice
760+
else None
761+
),
762+
"land": (
763+
f"{case_dir}/post/lnd/glb/ts/monthly/{ts_num_years}yr/"
764+
if plots_lnd
765+
else None
766+
),
767+
"ocean": (
768+
f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
769+
if use_ocn
770+
else None
771+
),
772+
"moc": (
773+
f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
774+
if use_ocn
775+
else None
776+
),
777+
"vol": (
778+
f"{case_dir}/post/ocn/glb/ts/monthly/{ts_num_years}yr/"
779+
if use_ocn
780+
else None
781+
),
769782
"name": experiment_name,
770783
"yoffset": 0.0,
771784
"yr": ([year1, year2],),

zppy/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class DependencySkipError(RuntimeError):
3232

3333
def get_active_status(task: Dict[str, Any]) -> bool:
3434
active: Any = task["active"]
35-
if type(active) == bool:
35+
if isinstance(active, bool):
3636
return active
37-
elif type(active) == str:
37+
elif isinstance(active, str):
3838
active_lower_case: str = active.lower()
3939
if active_lower_case == "true":
4040
return True
@@ -73,6 +73,7 @@ def get_url_message(c: Dict[str, Any], task: str) -> str:
7373

7474
# Beginning steps #############################################################
7575

76+
7677
# TODO: determine return type
7778
def initialize_template(config: ConfigObj, template_name: str) -> Tuple[Any, Any]:
7879
# --- Initialize jinja2 template engine ---
@@ -87,6 +88,7 @@ def initialize_template(config: ConfigObj, template_name: str) -> Tuple[Any, Any
8788
# TODO: type aliases require python 3.12 or higher
8889
# type TaskDict = Dict[str, Any]
8990

91+
9092
# Process specified section and its sub-sections to build the list of tasks.
9193
# If the section includes sub-sections, one task will be created for each
9294
# sub-section and no task will be created for the main section.
@@ -149,7 +151,7 @@ def get_tasks(config: ConfigObj, section_name: str) -> List[Dict[str, Any]]:
149151
username = os.environ.get("USER")
150152
for c in tasks:
151153
for key in c:
152-
if (type(c[key]) == str) and ("$USER" in c[key]):
154+
if (isinstance(c[key], str)) and ("$USER" in c[key]):
153155
c[key] = c[key].replace("$USER", username)
154156

155157
return tasks
@@ -240,7 +242,7 @@ def check_required_parameters(
240242
# "year_begin-year_end"
241243
def get_years(years_input) -> List[Tuple[int, int]]:
242244
years_list: List[str]
243-
if type(years_input) == str:
245+
if isinstance(years_input, str):
244246
# This will be the case if years_list is missing a trailing comma
245247
years_list = [years_input]
246248
else:
@@ -272,6 +274,7 @@ def get_years(years_input) -> List[Tuple[int, int]]:
272274

273275
# `for s in year_sets` steps ##################################################
274276

277+
275278
# This returns a value
276279
def define_or_guess(
277280
c: Dict[str, Any],

0 commit comments

Comments
 (0)