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

Emit a warning on invalid syntax in files or in doc code-blocks #23

Closed
Zac-HD opened this issue Sep 15, 2021 · 3 comments
Closed

Emit a warning on invalid syntax in files or in doc code-blocks #23

Zac-HD opened this issue Sep 15, 2021 · 3 comments

Comments

@Zac-HD
Copy link
Owner

Zac-HD commented Sep 15, 2021

echo 1/ > t.py && shed t.py reports an internal error, because the file contents are not syntactically valid Python. We should just emit a warning in this case. CC @rsokl 😉

@Zac-HD Zac-HD changed the title Internal error on invalid syntax; should be a warning Emit a warning on invalid syntax in files or in doc code-blocks Sep 15, 2021
@Zac-HD
Copy link
Owner Author

Zac-HD commented Sep 15, 2021

As of shed == 0.4.1, this is no longer an error - but we silently skip such broken bits of code, and I'd prefer to emit a warning or print to stderr. Challenge: thread through a location param to use in such a warning, and ideally make it warning when used in code - caught and printed to stderr when in the CLI.

@rsokl
Copy link

rsokl commented Sep 15, 2021

Sorry for not just opening an issue earlier! I can confirm that the internal errors I was getting on 0.3.10, e.g.

Internal error formatting 'README.md': Cannot parse: 1:0: >>> from hydra_zen import builds

were indeed related to me using a python code block where I should be using a pycon one. I can also confirm that 0.4.1 runs without issue on the same project!

@Zac-HD
Copy link
Owner Author

Zac-HD commented Sep 16, 2021

Fixed by c2414fe: from version 0.4.2, shed reports

$ shed hydra-zen/README.md
Could not parse ```python markdown block in file 'hydra-zen/README.md'
    Perhaps you should use a 'pycon' block instead?
Could not parse ```python markdown block in file 'hydra-zen/README.md'
    Perhaps you should use a 'pycon' block instead?

and successfully formats the actually-python code blocks in the same pass 🚀

@Zac-HD Zac-HD closed this as completed Sep 16, 2021
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

No branches or pull requests

2 participants