-
-
Notifications
You must be signed in to change notification settings - Fork 883
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
Treat warnings as errors #1687
Treat warnings as errors #1687
Conversation
… partially initialized instances
Weirdly, at this point the 3.10 test runs are hanging, but there's not any feedback to guide where or why. |
Ran tests locally, I find that it is because the uvicorn server failed to start if we treat warnings as error: We need to get uvicorn running under 3.10 without warnings first. Related: encode/uvicorn#1070 |
@j178 Fantastic bit of digging, thanks! Okay, so blocked on a 3.10 compatriot uvicorn release. Gotcha. |
setup.cfg
Outdated
@@ -15,7 +15,7 @@ profile = black | |||
combine_as_imports = True | |||
|
|||
[tool:pytest] | |||
addopts = -rxXs | |||
addopts = -rxXs -Werror |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use filterwarnings=error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reminds me that we can use
filterwarnings =
error
default:::uvicorn
to exempt uvicorn
warnings, so that we will not be blocked by uvicorn
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use filterwarnings=error
Could you expand on that @graingert?
to exempt uvicorn warnings, so that we will not be blocked by uvicorn.
Oh, that's a great tip, @j178. I'm not sure what I need to do to inline that here, but will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, cribbing an example from here pytest-dev/pytest#4180
[tool:pytest]
addopts =
-W error
-v
filterwarnings =
error
# ignored by default
ignore::ImportWarning
ignore::PendingDeprecationWarning
# raised by Cython, usually harmless
ignore:numpy.dtype size changed:RuntimeWarning
ignore:numpy.ufunc size changed:RuntimeWarning
# raised by Werkzeug
ignore:Request.is_xhr is deprecated:DeprecationWarning
# raised by Moto
ignore:Flags not at the start of the expression:DeprecationWarning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filterwarnings in option is preferred eg https://github.com/pytest-dev/pytest/blob/main/pyproject.toml#L23
…encode/httpx into pytest-treat-warnings-as-errors
Okay, gave that a try. Looks like 3.10 is still stuck. |
@tomchristie drop |
…encode/httpx into pytest-treat-warnings-as-errors
Alrighty, ready for review I think. |
Closes #1686
Closes #1670
-Werror
when running pytest, to treat warnings as errors.try..finally
around auth_flow generator usage, with a.close()
in the finally block.getattr
in__del__
to handle a case where an attribute might not exist on a partially initialised instance.open()
file in a test case.ssl.PROTOCOL_TLS_CLIENT
instead of deprecatedssl.PROTOCOL_TLS
context.minimum_version =
instead ofcontext.options |= ssl.OP_NO_*
on Python 3.10+