Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1. Content and background
Some coding style suggestions (including one possible bugfix).
2. Summary of corrections
I went over the following:
Removed
Optional
where it was incorrectly specified in a type annotation Added someLiteral
type annotations.Optional
should only be specified when the argument can receiveNone
as a value, which was not true in most cases. From Python docs:Moved traceback printing calls to logging.
Raise exceptions instead of
sys.exit()
. This makes it easier to use within another script.Do not use base
except
. This has the side-effect of catchingKeyboardInterrupt
too which is most likely not what is wanted.Ran
black
for styling and went over some offlake8
linting comments (e.g. removef
prefix when the f-string has no placeholder, etc.).The latter revealed that a call to
gs.export_onnx()
was using an undefined variablegraph
. This bug was introduced in commit 85147eb,I had a mistake in one of the commits with a call to
warn_tb
that I didn't correct until a later commit. But the final results is OK.If need be, I can prepare a pull request with only a subset of these changes. I avoided making any functional changes, only focusing on style.