From c8f846caa4f88b7331c1da75d5fd3ba75830f104 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Fri, 22 Nov 2024 08:30:15 +1300 Subject: [PATCH] refactor: resolve ruff check F821 for undefined name (#2062) * refactor: resolve ruff check F821 for undefined name * Update test_gwf_lak_wetlakbedarea01.py * Update test_gwe_esl02.py make codespell happy * ruff --------- Co-authored-by: Eric Morway Co-authored-by: langevin-usgs --- autotest/test_gwe_esl02.py | 3 ++- autotest/test_gwe_obs.py | 2 +- autotest/test_gwf_lak_wetlakbedarea01.py | 6 ------ autotest/test_gwf_laket.py | 1 + doc/mf6io/mf6ivar/mf6ivar.py | 6 ++---- ruff.toml | 1 - 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/autotest/test_gwe_esl02.py b/autotest/test_gwe_esl02.py index 90008ccd2ea..1098d808ae5 100644 --- a/autotest/test_gwe_esl02.py +++ b/autotest/test_gwe_esl02.py @@ -340,7 +340,8 @@ def check_output(idx, test): "Grid cell temperatures do not reflect the expected difference" "in stress period " ) - assert np.isclose(np.sum(temps[-1]), ncol[idx]), msg0 + str(index) + answer = ncol[idx] + assert np.isclose(np.sum(temps[-1]), answer), msg0 + str(idx) # - No need to change any code below diff --git a/autotest/test_gwe_obs.py b/autotest/test_gwe_obs.py index a15b0967fb2..9d3855cab59 100644 --- a/autotest/test_gwe_obs.py +++ b/autotest/test_gwe_obs.py @@ -488,7 +488,7 @@ def check_output(idx, test): # return out of function return None else: - assert error_count == 0, errmsg0 + assert error_count == 0 name = cases[idx] gwename1 = "gwe-" + name + "-1" diff --git a/autotest/test_gwf_lak_wetlakbedarea01.py b/autotest/test_gwf_lak_wetlakbedarea01.py index e2f2055d236..f94ed302c11 100644 --- a/autotest/test_gwf_lak_wetlakbedarea01.py +++ b/autotest/test_gwf_lak_wetlakbedarea01.py @@ -141,12 +141,6 @@ def calc_qSat(top, bot, thk): else: y = 1.0 - else: - if x < bot: - y = 0.0 - else: - y = 1.0 - return y diff --git a/autotest/test_gwf_laket.py b/autotest/test_gwf_laket.py index 1b97441afa3..26863de710b 100644 --- a/autotest/test_gwf_laket.py +++ b/autotest/test_gwf_laket.py @@ -286,6 +286,7 @@ def check_output(idx, test): stage_compare = True test.success = True + msg = "" if not evap_compare: test.success = False msg += " Lake evaporation comparison failed." diff --git a/doc/mf6io/mf6ivar/mf6ivar.py b/doc/mf6io/mf6ivar/mf6ivar.py index ad4deeca5d6..fae2434499a 100644 --- a/doc/mf6io/mf6ivar/mf6ivar.py +++ b/doc/mf6io/mf6ivar/mf6ivar.py @@ -157,7 +157,7 @@ def parse_mf6var_file(fname): else: key = name if key in vardict: - raise ValueError(f"Variable already exists in dictionary: {k}") + raise ValueError(f"Variable already exists in dictionary: {key}") vardict[key] = vd vd = {} continue @@ -233,9 +233,7 @@ def block_entry(varname, block, vardict, prefix=" "): elif " " in vtype: vtype = vtype.split(" ", 1)[0] if vtype not in VALID_TYPES: - raise ValueError( - f"{fname}: {key}: {vtype!r} is not a valid type from {VALID_TYPES}" - ) + raise ValueError(f"{key}: {vtype!r} is not a valid type from {VALID_TYPES}") # record or recarray if v["type"].startswith("rec"): diff --git a/ruff.toml b/ruff.toml index a8802328d7e..c0a4134f39e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -11,7 +11,6 @@ select = [ ignore = [ "E722", # do not use bare `except` "E741", # ambiguous variable name - "F821", # undefined name TODO FIXME "F841", # local variable assigned but never used ]