Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve linting output and display of warnings #340

Merged
merged 6 commits into from
Mar 4, 2024
Merged

Conversation

nielstron
Copy link
Contributor

@nielstron nielstron commented Mar 3, 2024

This adjustment brings three improvements to OpShin and resolves #160

  • The --verbose option is added to the compiler, allowing more in-depth details about the compilation process to be seen by the user. This will allow better insights into why compilation fails or checking which optimizations have been applied
  • Logger warnings are now printed together with the location in the file in which they occur. Previously, warnings have been printed without any context, making it hard to map to their origin, which is crucial for users.
  • Logger warnings are among the linting output in the default linter format. This allows improving the opshin-vscode extension, that makes syntax errors easily visible in VSCode

An example for the change with the warning when compiling examples/datum_cast.py:

Previously:

$ opshin build examples/datum_cast.py                    
The string b'1234' looks like it is supposed to be a hex-encoded bytestring but is actually utf8-encoded. Try using `bytes.fromhex('1234')` instead.
Wrote script artifacts to build/datum_cast/
$ opshin lint examples/datum_cast.py 2> /dev/stdout
$ opshin lint examples/datum_cast.py --output-format-json 2> /dev/stdout

Now:

$ opshin build examples/datum_cast.py                    
examples/datum_cast.py:25:16:WARNING:The string b'1234' looks like it is supposed to be a hex-encoded bytestring but is actually utf8-encoded. Try using `bytes.fromhex('1234')` instead.
Wrote script artifacts to build/datum_cast/
$ opshin lint examples/datum_cast.py 2> /dev/stdout 
examples/datum_cast.py:25:16:WARNING: The string b'1234' looks like it is supposed to be a hex-encoded bytestring but is actually utf8-encoded. Try using `bytes.fromhex('1234')` instead.
$ opshin lint examples/datum_cast.py --output-format-json 2> /dev/stdout
{"line":25,"column":16,"error_class":"WARNING","message":"The string b'1234' looks like it is supposed to be a hex-encoded bytestring but is actually utf8-encoded. Try using `bytes.fromhex('1234')` instead."}

@nielstron nielstron merged commit 83c4385 into dev Mar 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant