Skip to content

Commit 2b44213

Browse files
change valueerror to warning for un-formatted {} values. Useful for in-code procesing of strings
1 parent d043e48 commit 2b44213

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

schimpy/schism_yaml.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import re
1919
import os
2020
import argparse
21+
import warnings
2122
import sys
2223

2324
__all__ = ["load", "dump", "YamlAction", "ArgumentParserYaml"]
@@ -41,10 +42,8 @@ def check_env(env):
4142
if "$" in k:
4243
msg += "A Name of environment variable cannot be a variable: " "%s\n" % k
4344
n_errors += 1
44-
if not isinstance(v, str):
45-
msg += (
46-
"Environment variables do not accept non-scalar " "variables: %s\n" % k
47-
)
45+
if not isinstance(v, (str, float, int)):
46+
msg += "Environment variables do not accept non-scalar variables: %s\n" % k
4847
n_errors += 1
4948
if n_errors > 0:
5049
raise ValueError(msg)
@@ -295,7 +294,7 @@ def load(stream, envvar=None):
295294
for path, matches in unsub:
296295
msg.append(f" {path}: {matches}")
297296
msg.append(r"This could be an issue of using {var} instead of ${var}")
298-
raise ValueError("\n".join(msg))
297+
warnings.warn("\n".join(msg))
299298
return data
300299
finally:
301300
loader.dispose()

0 commit comments

Comments
 (0)