Skip to content

STYLE use subprocess to validate flake8 on docstrings instead of Application #40784

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

Closed
MarcoGorelli opened this issue Apr 5, 2021 · 1 comment · Fixed by #40812
Closed

STYLE use subprocess to validate flake8 on docstrings instead of Application #40784

MarcoGorelli opened this issue Apr 5, 2021 · 1 comment · Fixed by #40812
Assignees
Labels
Code Style Code style, linting, code_checks
Milestone

Comments

@MarcoGorelli
Copy link
Member

According to flake8's creator, the Application class from flake8 isn't meant to be used a library. As their sole maintainer isn't the original author, the library's internals could well change without warning, and this would break scripts/validate_docstrings.

This part probably wants changing:

application = flake8.main.application.Application()
application.initialize(["--quiet"])
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as file:
file.write(content)
file.flush()
application.run_checks([file.name])
# We need this to avoid flake8 printing the names of the files to
# the standard output
application.formatter.write = lambda line, source: None
application.report()
yield from application.guide.stats.statistics_for("")

We're already writing the docstring to a temporary file, so we could just run flake8 on that via subprocess.run

@MarcoGorelli MarcoGorelli added the Code Style Code style, linting, code_checks label Apr 5, 2021
@hasan-yaman
Copy link
Contributor

take

@jreback jreback added this to the 1.3 milestone Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants