Skip to content

Fail CI on encountering deprecation warnings#404

Merged
AlexWaygood merged 5 commits intoPyCQA:mainfrom
AlexWaygood:warnings-into-errors
Jul 1, 2023
Merged

Fail CI on encountering deprecation warnings#404
AlexWaygood merged 5 commits intoPyCQA:mainfrom
AlexWaygood:warnings-into-errors

Conversation

@AlexWaygood
Copy link
Collaborator

@AlexWaygood AlexWaygood commented Jun 26, 2023

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 -Wa to subprocess.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

@AlexWaygood AlexWaygood requested a review from Akuli June 26, 2023 21:46

[tool.pytest.ini_options]
addopts = "--doctest-modules"
filterwarnings = ["error"]
Copy link
Collaborator Author

@AlexWaygood AlexWaygood Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +52 to +59
flake8_invocation = [
sys.executable,
"-Wignore",
"-Wdefault:::pyi",
"-m",
"flake8",
"-j0",
]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I've manually checked that this causes CI to fail if we have DeprecationWarnings that are emitted from flake8-pyi itself)

@AlexWaygood AlexWaygood requested a review from Akuli June 27, 2023 13:04
Copy link
Member

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea to me, but I'll wait for a third opinion.

@AlexWaygood AlexWaygood merged commit 5792181 into PyCQA:main Jul 1, 2023
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 this pull request may close these issues.

Drop support for Python 3.7

3 participants