Fail CI on encountering deprecation warnings#404
Merged
AlexWaygood merged 5 commits intoPyCQA:mainfrom Jul 1, 2023
Merged
Conversation
AlexWaygood
commented
Jun 26, 2023
|
|
||
| [tool.pytest.ini_options] | ||
| addopts = "--doctest-modules" | ||
| filterwarnings = ["error"] |
Collaborator
Author
There was a problem hiding this comment.
This can still catch DeprecationWarnings emitted during the doctests that we run in CI, but it doesn't do anything for any DeprecationWarnings emitted during the tests in tests/test_pyi_files.py
Akuli
reviewed
Jun 27, 2023
AlexWaygood
commented
Jun 27, 2023
Co-authored-by: Akuli <[email protected]>
AlexWaygood
commented
Jun 27, 2023
Comment on lines
+52
to
+59
| flake8_invocation = [ | ||
| sys.executable, | ||
| "-Wignore", | ||
| "-Wdefault:::pyi", | ||
| "-m", | ||
| "flake8", | ||
| "-j0", | ||
| ] |
Collaborator
Author
There was a problem hiding this comment.
(I've manually checked that this causes CI to fail if we have DeprecationWarnings that are emitted from flake8-pyi itself)
srittau
approved these changes
Jun 27, 2023
Member
srittau
left a comment
There was a problem hiding this comment.
Sounds like a good idea to me, but I'll wait for a third opinion.
AlexWaygood
commented
Jun 27, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because we run flake8 via a subprocess in our test suite, pytest can't detect any DeprecationWarnings emitted while the plugin is being run. This PR therefore passes
-Watosubprocess.run(), so that we can capture any DeprecationWarnings emitted in the subprocess, and fail CI if any are emitted.Some DeprecationWarnings are currently emitted on Python 3.12 by pyflakes and flake8-bugbear, so those need to be ignored in order for this approach to work.
Closes #392