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

Replace noqa directive parser with an actual lexer #5616

Closed
charliermarsh opened this issue Jul 8, 2023 · 1 comment
Closed

Replace noqa directive parser with an actual lexer #5616

charliermarsh opened this issue Jul 8, 2023 · 1 comment
Labels
suppression Related to supression of violations e.g. noqa

Comments

@charliermarsh
Copy link
Member

In #5567 and related PRs, I moved away from regular expressions and exact matches to a more token-based approach to noqa parsing. There are two codepaths here, one for # noqa: F401 (inline exemptions) and another for # ruff: noqa: F401 (whole-file exemptions). We should replace both of these with an actual lexer to lex directives, and then match against the resulting token stream. That would likely simplify the code a lot and allow us to unify the implementations.

@charliermarsh charliermarsh added the suppression Related to supression of violations e.g. noqa label Jul 8, 2023
@charliermarsh
Copy link
Member Author

Low-priority. We could in theory though use this same lexer for (e.g.) # isort: on directives. We could even use this approach to support autoformatting of directives.

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suppression Related to supression of violations e.g. noqa
Projects
None yet
Development

No branches or pull requests

1 participant