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

Print error in lesson_check.py if code block has no class specifier #550

Closed
tomgreen66 opened this issue Feb 23, 2021 · 2 comments · Fixed by #558
Closed

Print error in lesson_check.py if code block has no class specifier #550

tomgreen66 opened this issue Feb 23, 2021 · 2 comments · Fixed by #558

Comments

@tomgreen66
Copy link
Contributor

So I think we need a:

            if cls is None:
                print(self.filename, self.get_loc(node))

That's a good idea with one comment: we need to make sure it's clear that this is an error message and to either halt the execution of lesson-check or skip to the next file when this happens because we can't produce an AST of (and, therefore, analyze) the current file. Would you like to submit a PR with this fix?

Originally posted by @maxim-belkin in #543 (comment)

@tomgreen66
Copy link
Contributor Author

Have maybe improved upon suggestion to add another check and just include the check for cls is None in the self.reporter.check and in the process make it cls is not None. See:

ARCCA/styles@661de87

@zkamvar
Copy link
Contributor

zkamvar commented Mar 11, 2021

The solution does work, but this allows the AST to be malformed because we expect that all code blocks should have a class associated.

I think the deeper problem is HOW the AST is malformed, because it could be via user error or, as we saw in #543, a parser error. Because None is an unexpected condition which could be caused by either user or parser, it would not be a good idea to throw an error, because that would end up frustrating users if it's the fault of the parser and the lesson is otherwise fine.

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 a pull request may close this issue.

2 participants