Skip to content

Commit

Permalink
add Int/Float hint
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Jul 23, 2020
1 parent deda91d commit e457b78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 2 additions & 5 deletions WDL/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,7 @@ def print_error(exn):
if sys.stderr.isatty():
sys.stderr.write(ANSI.BHRED)
if isinstance(getattr(exn, "pos", None), SourcePosition):
print(
"({} Ln {} Col {}) {}".format(exn.pos.uri, exn.pos.line, exn.pos.column, str(exn)),
file=sys.stderr,
)
print(f"({exn.pos.uri} Ln {exn.pos.line} Col {exn.pos.column}) {exn}", file=sys.stderr)
else:
print(str(exn), file=sys.stderr)
if sys.stderr.isatty():
Expand Down Expand Up @@ -710,7 +707,7 @@ def file_found(fn):
msg = info["message"]
del info["message"]
logger.error(_(msg, **info))
if kwargs["debug"]:
if isinstance(exn, AssertionError) or kwargs["debug"]:
raise
sys.exit(exit_status)
finally:
Expand Down
6 changes: 4 additions & 2 deletions WDL/Error.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ def __init__(
super().__init__(node, message)

def __str__(self) -> str:
msg = "Expected {} instead of {}".format(str(self.expected), str(self.actual))
msg = f"Expected {self.expected} instead of {self.actual}"
if self.message:
msg += " " + self.message
msg += "; " + self.message
elif isinstance(self.expected, Type.Int) and isinstance(self.actual, Type.Float):
msg += "; perhaps try floor() or round()"
return msg


Expand Down

0 comments on commit e457b78

Please sign in to comment.