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

Integrate warnings filtering directly into Config #7700

Merged

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Aug 29, 2020

Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix #6681
Fix #2891
Fix #7426
Fix #7626
Close #7649

Warnings are a central part of Python, so much that Python itself has
command-line and environtment variables to handle warnings.

By moving the concept of warning handling into Config, it becomes natural to
filter warnings issued as early as possible, even before the "_pytest.warnings"
plugin is given a chance to spring into action. This also avoids the weird
coupling between config and the warnings plugin that was required before.

Fix pytest-dev#6681
Fix pytest-dev#2891
Fix pytest-dev#7620
Fix pytest-dev#7626
Close pytest-dev#7649
@nicoddemus nicoddemus force-pushed the refactor-config-warnings-6681 branch from 854867a to 340cea2 Compare August 29, 2020 15:33
@The-Compiler
Copy link
Member

This probably breaks -p no:warnings, right? Looks like there are a couple hundred repos using that: https://github.com/search?q=%22-p+no%3Awarnings%22&type=Code

@nicoddemus
Copy link
Member Author

This probably breaks -p no:warnings, right?

Possibly, depending on the reasons -p no:warnings is used for... any suggestions on how to proceed?

@nicoddemus
Copy link
Member Author

This probably breaks -p no:warnings, right?

Possibly, depending on the reasons -p no:warnings is used for... any suggestions on how to proceed?

Hmmm actually this does not really change things: the _issue_warning_captured function would always be executed before, regardless of -p no:warning being given in the command-line. All this PR does is to make filterwarnings and --pythonwarnings always available, and have a public Config function to issue the config warnings instead of an internal function in the warnings plugin.

We can however improve this even further by not doing anything in issue_config_time_warning in case the warnings plugin is blocked.

@nicoddemus
Copy link
Member Author

We can however improve this even further by not doing anything in issue_config_time_warning in case the warnings plugin is blocked.

Done! This is now even safer than before, because even config time warnings are not issued anymore with -p no:warnings.

Thanks @The-Compiler. 👍

@nicoddemus
Copy link
Member Author

We can however improve this even further by not doing anything in issue_config_time_warning in case the warnings plugin is blocked.

Done! This is now even safer than before, because config time warnings are also blocked by -p no:warnings.

Thanks @The-Compiler!

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

One less cyclic dependency, nice!

testing/test_config.py Outdated Show resolved Hide resolved
src/_pytest/config/__init__.py Outdated Show resolved Hide resolved
src/_pytest/config/__init__.py Outdated Show resolved Hide resolved
nicoddemus and others added 2 commits September 4, 2020 11:34
@nicoddemus nicoddemus merged commit 19e99ab into pytest-dev:master Sep 4, 2020
@nicoddemus nicoddemus deleted the refactor-config-warnings-6681 branch September 4, 2020 14:57
@pllim
Copy link
Contributor

pllim commented Sep 4, 2020

👏 Thank you! Which release should I expect this patch to be in? I'll be on the look out. 😄

@nicoddemus
Copy link
Member Author

nicoddemus commented Sep 4, 2020

6.1, which should be out soon (#7703). 👍

nicoddemus added a commit to ssbarnea/pytest that referenced this pull request Sep 9, 2020
lpasselin added a commit to shagren/pyk4a that referenced this pull request Sep 17, 2020
Fix will start workign with pytest 6.1 see pytest-dev/pytest#7700
lpasselin added a commit to etiennedub/pyk4a that referenced this pull request Sep 17, 2020
* Simple test

* More functions supported

* Fixes, Example

* Add code quality tool
Reformat code
Add type hintings
Fix code errors

* Add .mypy_cache to .gitignore

* Make line length 120 chars

* Initial playback support

* Seek support

* Add tests

* Format tests too

* Remove commented code

* Smaller asset.
Refactor tests.
Patch module for tests.

* Fix build

* Remove debug

* Validate if open() method called twice

* Remove unused file placeholder

* Better typing

* Merge develop
Refactor tests

* CI changes

* CI changes

* CI changes

* CI changes

* CI changes

* CI changes

* Some changes in tests definitions

* Fix Maklefile
Remove unused total_capsules

* Fix

* Update playback_seek_timestamp function description

* Typofix

* Update readme with small details.

* rename _thread_safe to thread_safe

* reformat line for readability

* force ubuntu-18.04. Version supported by SDK

* WIP

* WIP

* Fix build

* Rebase mkv-support-3

* Refactor tests
Add unit tests

* WIP: color controls

* More color-module tests
CI

* Refactor device_get_color_control_capabilities()

* WIP: IMU support

* CI fix

* start/stop cameras support

* device_get_capture support

* Remove debug lines

* support of get_capture, get_imu_sample

* WIP: Calibration

* WIP: Capture

* Support device_get_raw_calibration

* Support creating calibration from json file

* convert_3d_to_3d support

* calibration_2d_to_3d support

* WIP: Transformations support

* Transformation functions

* Refactor transformation

* Refactor examples

* Add benchmark example

* Fix tests

* Better playback example
get_previouse_capture support

* Fix playback example

* Rollback some text changes

* rename capsule_xxxx_name to CAPSULE_XXXX_NAME

* Text fix

* Typo fix

* Refactor examples

* CR changes

* CR changes

* CR changes

* CR changes

* CR changes

* add py.typed to distribution

* remove not required _start_imu() call

* fix PytestAssertRewriteWarning

Fix will start workign with pytest 6.1 see pytest-dev/pytest#7700

Co-authored-by: Louis-Philippe Asselin <louisphilippeasselin@gmail.com>
Co-authored-by: Louis-Philippe Asselin <lpasselin@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment