Skip to content

Commit f7fec57

Browse files
committed
fix ruff lints
1 parent 1a8bd3e commit f7fec57

File tree

3 files changed

+53
-56
lines changed

3 files changed

+53
-56
lines changed

gsw/tests/_WIP_test_ufuncs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ def cfcf(request):
2929

3030
def test_mechanism(cfcf):
3131
cv, cf, mfunc = cfcf
32-
print("<%s>" % mfunc.name)
32+
print(f"<{mfunc.name}>")
3333
def value_from_name(vname):
3434
b, name = vname.split('.')
3535
if b == 'cf':
3636
return cf[name]
3737
elif b == 'cv':
3838
return cv[name]
3939
else:
40-
raise ValueError("Can't find cf. or cv. in %s" % vname)
40+
raise ValueError(f"Can't find cf. or cv. in {vname}")
4141
def set_from_name(vname, value):
4242
b, name = vname.split('.')
4343
if b == 'cf':
@@ -76,10 +76,10 @@ def set_from_name(vname, value):
7676
#set_from_name(mfunc.test_varstrings[0], expected - found)
7777

7878
else:
79-
print(">>%s<<" % mfunc.testline)
79+
print(f">>{mfunc.testline}<<")
8080
print("missing mfunc.test_varstrings")
8181
mfunc.run()
82-
if hasattr(mfunc, 'exception'):
83-
print(">>>%s<<<", mfunc.exception)
82+
if hasattr(mfunc, "exception"):
83+
print(f">>>{mfunc.exception}<<<")
8484
else:
8585
assert mfunc.passed

gsw/tests/check_functions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def run(self, locals_=None):
177177

178178
# The following is needed for melting_ice_into_seawater.
179179
if len(self.outstrings) > 1:
180-
rl_ind = '[:%d]' % len(self.outstrings)
180+
rl_ind = f"[:{len(self.outstrings)}]"
181181
else:
182-
rl_ind = ''
182+
rl_ind = ""
183183

184184
exec(self.runline + rl_ind, *evalargs)
185185
if len(self.outstrings) == 1:
@@ -327,13 +327,13 @@ def parse_check_functions(mfile):
327327
isinstance(f.exception, exc)]
328328
ex_dict[exc] = elist
329329

330-
print("\n%s tests were translated from gsw_check_functions.m" % len(checks))
331-
print("\n%s tests ran with no error and with correct output" % len(passes))
330+
print(f"\n{len(checks)} tests were translated from gsw_check_functions.m")
331+
print(f"\n{len(passes)} tests ran with no error and with correct output")
332332
if args.verbose:
333333
for f in passes:
334334
print(f.name)
335335

336-
print("\n%s tests had an output mismatch:" % len(failures))
336+
print(f"\n{len(failures)} tests had an output mismatch:")
337337
for f in failures:
338338
print(f.name)
339339
print(f.runline)
@@ -348,7 +348,7 @@ def parse_check_functions(mfile):
348348

349349
print('')
350350

351-
print("\n%s exceptions were raised as follows:" % len(run_problems))
351+
print(f"\n{len(run_problems)} exceptions were raised as follows:")
352352
for exc in etypes:
353353
print(" ", exc.__name__)
354354
strings = [" {} : {}".format(*e) for e in ex_dict[exc]]

pyproject.toml

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
build-backend = "setuptools.build_meta"
33
requires = [
44
"build",
5-
'numpy<3,>=2.0.0rc1; python_version >= "3.9"',
6-
'oldest-supported-numpy; python_version < "3.9"',
5+
"numpy>=2.0.0rc1,<3; python_version>='3.9'",
6+
"oldest-supported-numpy; python_version<'3.9'",
77
"pip>9.0.1",
88
"setuptools>=42",
9-
"setuptools_scm[toml]>=3.4",
9+
"setuptools-scm[toml]>=3.4",
1010
"wheel",
1111
]
1212

1313
[project]
1414
name = "gsw"
1515
description = "Gibbs Seawater Oceanographic Package of TEOS-10"
16-
license = {text = "BSD-3-Clause"}
16+
license = { text = "BSD-3-Clause" }
1717
authors = [
18-
{name = "Eric Firing, Filipe Fernandes", email = "[email protected]"},
18+
{ name = "Eric Firing, Filipe Fernandes", email = "[email protected]" },
1919
]
2020
requires-python = ">=3.8"
2121
classifiers = [
@@ -30,6 +30,7 @@ classifiers = [
3030
"Programming Language :: Python :: 3.10",
3131
"Programming Language :: Python :: 3.11",
3232
"Programming Language :: Python :: 3.12",
33+
"Programming Language :: Python :: 3.13",
3334
"Topic :: Scientific/Engineering",
3435
]
3536
dynamic = [
@@ -39,71 +40,67 @@ dynamic = [
3940
dependencies = [
4041
"numpy>=1.21",
4142
]
42-
[project.urls]
43-
documentation = "https://teos-10.github.io/GSW-Python/"
44-
homepage = "https://www.teos-10.org/"
45-
repository = "https://github.com/TEOS-10/GSW-python"
43+
urls.documentation = "https://teos-10.github.io/GSW-Python/"
44+
urls.homepage = "https://www.teos-10.org/"
45+
urls.repository = "https://github.com/TEOS-10/GSW-python"
4646

4747
[tool.setuptools]
48-
license-files = ["LICENSE.txt"]
48+
license-files = [ "LICENSE.txt" ]
4949
zip-safe = false
5050
include-package-data = true
51-
packages = ["gsw", "gsw.tests"]
52-
51+
packages = [ "gsw", "gsw.tests" ]
5352

5453
[tool.setuptools.dynamic]
55-
dependencies = {file = ["requirements.txt"]}
56-
readme = {file = "README.md", content-type = "text/markdown"}
54+
dependencies = { file = [ "requirements.txt" ] }
55+
readme = { file = "README.md", content-type = "text/markdown" }
5756

5857
[tool.setuptools_scm]
5958
write_to = "gsw/_version.py"
6059
write_to_template = "__version__ = '{version}'"
6160
tag_regex = "^(?P<prefix>v)?(?P<version>[^\\+]+)(?P<suffix>.*)?$"
6261

6362
[tool.ruff]
64-
lint.select = [
65-
"A", # flake8-builtins
66-
"B", # flake8-bugbear
67-
"C4", # flake8-comprehensions
68-
"F", # flakes
69-
"I", # import sorting
70-
"UP", # upgrade
71-
"NPY201", # numpy 2.0
72-
]
7363
target-version = "py38"
7464
line-length = 105
7565

76-
lint.ignore = [
77-
"F401", # module imported but unused
78-
"E501", # line too long
79-
"E713", # test for membership should be 'not in'
80-
]
81-
8266
exclude = [
8367
"tools",
8468
]
8569

86-
[tool.ruff.lint.per-file-ignores]
87-
"docs/conf.py" = [
88-
"A001", # variable is shadowing a python builtin
70+
lint.select = [
71+
"A", # flake8-builtins
72+
"B", # flake8-bugbear
73+
"C4", # flake8-comprehensions
74+
"F", # flakes
75+
"I", # import sorting
76+
"NPY201", # numpy 2.0
77+
"UP", # upgrade
8978
]
90-
"gsw/_fixed_wrapped_ufuncs.py" = [
91-
"F403", #'from x import *' used; unable to detect undefined names
92-
"F405", # 'import' may be undefined, or defined from star imports
79+
lint.ignore = [
80+
"E501", # line too long
81+
"E713", # test for membership should be 'not in'
82+
"F401", # module imported but unused
9383
]
9484

95-
"gsw/_utilities.py" = [
96-
"B904", # Within an ``except`` clause, raise exceptions with ``raise ... from err``
85+
lint.per-file-ignores."docs/conf.py" = [
86+
"A001", # variable is shadowing a python builtin
87+
]
88+
lint.per-file-ignores."gsw/_fixed_wrapped_ufuncs.py" = [
89+
"F403", #'from x import *' used; unable to detect undefined names
90+
"F405", # 'import' may be undefined, or defined from star imports
91+
]
92+
lint.per-file-ignores."gsw/_utilities.py" = [
93+
"B904", # Within an ``except`` clause, raise exceptions with ``raise ... from err``
9794
]
9895

9996
[tool.check-manifest]
10097
ignore = [
101-
"*.yml",
102-
".coveragerc",
103-
"docs",
104-
"docs/*",
105-
"*.enc",
106-
"tools",
107-
"tools/*",
108-
"gsw/_version.py",
98+
"*.yml",
99+
".coveragerc",
100+
"docs",
101+
"docs/*",
102+
"*.enc",
103+
"tools",
104+
"tools/*",
105+
"gsw/_version.py",
109106
]

0 commit comments

Comments
 (0)