The Wayback Machine - https://web.archive.org/web/20220205142550/https://github.com/evhub/coconut/issues/556
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

Respect NOQA comments #556

Open
evhub opened this issue Sep 20, 2020 · 5 comments
Open

Respect NOQA comments #556

evhub opened this issue Sep 20, 2020 · 5 comments

Comments

@evhub
Copy link
Owner

@evhub evhub commented Sep 20, 2020

Should suppress --strict warnings.

@PhanatosZou
Copy link

@PhanatosZou PhanatosZou commented Jan 4, 2021

Hi, I'm new here and would love to take this issue. But I may need some help. Is there any advice on getting started? Any response will be appreciated!

@eindiran
Copy link
Contributor

@eindiran eindiran commented Jan 4, 2021

I think most of the changes should be to compiler/compiler.py, and potentially to compiler/util.py.

Take a look at the make_err and strict_err_or_warn methods, places where CoconutStyleError or CoconutSyntaxError are raised, and places where self.strict is checked. In case I am missing something, it is probably worth grepping through the whole repo for usages of strict.

For an example of how end-of-line comments are handled, see the function split_comment in compiler/util.py. split_comment returns a 2-tuple of base line and comment: the comment bit can be used to see if it matches the pattern of a noqa comment.

@PhanatosZou
Copy link

@PhanatosZou PhanatosZou commented Jan 4, 2021

@eindiran Thanks for your quick reply! I'll get started based on information you provided.

@evhub
Copy link
Owner Author

@evhub evhub commented Jan 8, 2021

Hmmm... I'm just realizing that the problem with this is that comments don't get added to Compiler.comments until Compiler.comment_handle is called, which only happens at the end of the line when the parser hits the comment. As a result, addressing this issue might be somewhat more complicated than I thought.

@evhub
Copy link
Owner Author

@evhub evhub commented Jan 8, 2021

I think the solution to this has to be to store strict errors/warnings rather than raising them immediately until Compiler.endline_handle is hit or parsing finishes, at which point stored errors can either be raised or suppressed based on whether a NOQA comment exists in Compiler.comments at that point.

@evhub evhub removed this from the v1.5.0 milestone Mar 5, 2021
@evhub evhub added this to the v1.5.1 milestone Mar 5, 2021
@evhub evhub removed the bounty: $15 label May 30, 2021
@evhub evhub removed this from the v1.6.0 milestone Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment