Open
Conversation
e439d85 to
9c9e3a2
Compare
Contributor
Author
|
/cc @pradyunsg @notatallshaw as this is related to the work in #215. I think it would actually be interesting to run #215 against the tests in this PR just as a form of regression tests. |
Contributor
Author
|
As a manual sanity check I did the following from my local clone of cd .nox/
./test-3-10/bin/python -m pip install -U pip
./test-3-10/bin/python -m pip install build -e ..
./test-3-10/bin/python -W ignore -m build ~/workspace/setuptools
# No warnings
./test-3-10/bin/python -W error -m build ~/workspace/setuptools
# ...
# File "/home/abravalheri/workspace/setuptools/setuptools/warnings.py", line 52, in emit
# warnings.warn(text, cls, stacklevel=stacklevel + 1)
# setuptools.config.pyprojecttoml._ExperimentalConfiguration: `[tool.distutils]` in `pyproject.toml` is still *experimental* and likely to change in future releases.
#
# ERROR Backend subprocess exited when trying to invoke build_sdist
./test-3-10/bin/python -W default -m build ~/workspace/setuptools
# ... a bunch of things, including:
# WARNING `[tool.distutils]` in `pyproject.toml` is still *experimental* and likely to change in future releases.
# ... |
abravalheri
commented
May 22, 2025
| """ | ||
| # `sys.warnoptions` is documented/mentioned in | ||
| # https://docs.python.org/3.13/library/warnings.html#describing-warning-filters | ||
| return chain.from_iterable(("-W", opt) for opt in sys.warnoptions) |
Contributor
Author
There was a problem hiding this comment.
Python docs do mention that sys.warnoptions should not be modified but they do not prevent reading it.
In fact, docs for 3.12 even include examples using it for quick checks https://docs.python.org/3.12/library/warnings.html#overriding-the-default-filter:
import sys
if not sys.warnoptions:
import warnings
warnings.simplefilter("ignore")
9c9e3a2 to
4c2fd35
Compare
Member
|
This makes sense to me, but as I haven't thought much about warnings and @pradyunsg has also worked on the topic in #215, I'd like to hear his view. |
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.
This PR is inspired by the discussions in:
The main idea is to forward whichever warning options have been specified for the "parent" process to the subprocess, as a complement to #157 1.
For example, if the user passes
python -W ignore -m build, then_in_process.pywould also be called with-W ignore.This is an initial investigation to test the waters, it can be incrementally improved based on feedback.
One thing that I considered is a finer control over the warnings or allowing the API callers to customise the values. But I rejected this idea as over engineering. Based on YAGNI, we can implement something very simple.
Footnotes
This way frontends could re-use Python's UI for warning filters without the necessity to implement their own. (They can still implement it if they want, but re-using Python's is handy). ↩