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

config option filterwarnings ignore::DeprecationWarning does not supress warnings #13145

Open
MarkusBiggus opened this issue Jan 19, 2025 · 2 comments

Comments

@MarkusBiggus
Copy link

Follow on from issue: config option filterwarnings ignore::DeprecationWarning:* crashes

Given the discussion, I should have mentioned the motivation for adding asterisk was because it didn't work without the asterisk. This is the real issue.

With Python3.12 when I tried to supress DeprecationWarning, I first used correct syntax:

[pytest]
minversion = 8.0
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
filterwarnings = ignore::DeprecationWarning

Which still shows deprecation warnings with Python3.13 too:

pytest tests/test_config_flow.py  -k test_options_flow_works
/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/josepy/util.py:26: DeprecationWarning: CSR support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
  def __init__(self, wrapped: Union[crypto.X509, crypto.X509Req]) -> None:
/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/acme/crypto_util.py:280: DeprecationWarning: CSR support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
  def _pyopenssl_cert_or_req_all_names(loaded_cert_or_req: Union[crypto.X509, crypto.X509Req]
/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/acme/crypto_util.py:291: DeprecationWarning: CSR support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
  def _pyopenssl_cert_or_req_san(cert_or_req: Union[crypto.X509, crypto.X509Req]) -> List[str]:
/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/acme/crypto_util.py:318: DeprecationWarning: CSR support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
  def _pyopenssl_cert_or_req_san_ip(cert_or_req: Union[crypto.X509, crypto.X509Req]) -> List[str]:
/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/acme/crypto_util.py:338: DeprecationWarning: CSR support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
  def _pyopenssl_extract_san_list_raw(cert_or_req: Union[crypto.X509, crypto.X509Req]) -> List[str]:
/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/acme/crypto_util.py:372: DeprecationWarning: X509Extension support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
  extensions: Optional[List[crypto.X509Extension]] = None,
/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/homeassistant/components/http/__init__.py:310: DeprecationWarning: Inheritance class HomeAssistantApplication from web.Application is discouraged
  class HomeAssistantApplication(web.Application):
Test session starts (platform: linux, Python 3.13.0, pytest 8.3.4, pytest-sugar 1.0.0)
rootdir: /home/homeassistant/sonnenbackup
configfile: pytest.ini
plugins: unordered-0.6.1, aiohttp-1.0.5, syrupy-4.8.0, xdist-3.6.1, asyncio-0.25.2, socket-0.7.0, mock-3.14.0, picked-0.5.0, cov-6.0.0, pytest_freezer-0.4.8, anyio-4.8.0, homeassistant-custom-component-0.13.201, timeout-2.3.1, respx-0.21.1, requests-mock-1.12.1, sugar-1.0.0, github-actions-annotate-failures-0.2.0
asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=function
collected 9 items / 8 deselected / 1 selected

I'd forgotten about it until Python3.13 crashed pytest.

pip list


Package                                 Version
--------------------------------------- -----------
acme                                    3.0.1
aiodns                                  3.2.0
aiohappyeyeballs                        2.4.4
aiohasupervisor                         0.2.2b5
aiohttp                                 3.11.11
aiohttp-cors                            0.7.0
aiohttp-fast-zlib                       0.2.0
aiooui                                  0.1.7
aiosignal                               1.3.2
aiozoneinfo                             0.2.1
annotated-types                         0.7.0
anyio                                   4.8.0
astral                                  2.2
async_interrupt                         1.2.0
async-timeout                           5.0.1
asyncio                                 3.4.3
asyncmock                               0.4.2
atomicwrites-homeassistant              1.4.1
attrs                                   24.2.0
audioop-lts                             0.2.1
awesomeversion                          24.6.0
bcrypt                                  4.2.0
bleak                                   0.22.3
bleak-retry-connector                   3.6.0
bluetooth-adapters                      0.20.2
bluetooth-auto-recovery                 1.4.2
bluetooth-data-tools                    1.20.0
boolean.py                              4.0
boto3                                   1.35.94
botocore                                1.35.94
btsocket                                0.3.0
certifi                                 2024.12.14
cffi                                    1.17.1
charset-normalizer                      3.4.1
ciso8601                                2.3.2
coverage                                7.6.8
cronsim                                 2.6
cryptography                            44.0.0
dbus-fast                               2.28.0
envs                                    1.4
execnet                                 2.1.1
fnv-hash-fast                           1.0.2
fnvhash                                 0.1.0
freezegun                               1.5.1
frozenlist                              1.5.0
h11                                     0.14.0
habluetooth                             3.7.0
hass-nabucasa                           0.87.0
home-assistant-bluetooth                1.13.0
homeassistant                           2025.1.0
httpcore                                1.0.7
httpx                                   0.27.2
idna                                    3.10
ifaddr                                  0.2.0
iniconfig                               2.0.0
isal                                    1.7.1
Jinja2                                  3.1.5
jmespath                                1.0.1
josepy                                  1.14.0
license-expression                      30.4.0
load-dotenv                             0.1.0
lru-dict                                1.3.0
MarkupSafe                              3.0.2
mashumaro                               3.15
mock                                    5.1.0
mock-open                               1.4.0
multidict                               6.1.0
numpy                                   2.2.0
orjson                                  3.10.12
packaging                               24.2
paho-mqtt                               1.6.1
pillow                                  11.0.0
pip                                     24.3.1
pipdeptree                              2.23.4
pluggy                                  1.5.0
propcache                               0.2.1
psutil                                  6.1.1
psutil-home-assistant                   0.0.1
pycares                                 4.5.0
pycognito                               2024.5.1
pycparser                               2.22
pydantic                                2.10.4
pydantic_core                           2.27.2
PyJWT                                   2.10.1
pylint-per-file-ignores                 1.3.2
pyOpenSSL                               24.3.0
pyRFC3339                               2.0.1
PyRIC                                   0.1.6.3
pytest                                  8.3.4
pytest-aiohttp                          1.0.5
pytest-asyncio                          0.25.2
pytest-cov                              6.0.0
pytest_freezer                          0.4.8
pytest-github-actions-annotate-failures 0.2.0
pytest-homeassistant-custom-component   0.13.201
pytest-mock                             3.14.0
pytest-picked                           0.5.0
pytest-socket                           0.7.0
pytest-sugar                            1.0.0
pytest-timeout                          2.3.1
pytest-unordered                        0.6.1
pytest-xdist                            3.6.1
python-dateutil                         2.9.0.post0
python-dotenv                           1.0.1
python-slugify                          8.0.4
pytz                                    2024.2
PyYAML                                  6.0.2
requests                                2.32.3
requests-mock                           1.12.1
responses                               0.25.3
respx                                   0.21.1
s3transfer                              0.10.4
securetar                               2024.11.0
setuptools                              75.7.0
six                                     1.17.0
sniffio                                 1.3.1
snitun                                  0.39.1
sonnen_api_v2                           0.5.13
SQLAlchemy                              2.0.36
standard-aifc                           3.13.0
standard-chunk                          3.13.0
standard-telnetlib                      3.13.0
syrupy                                  4.8.0
termcolor                               2.5.0
text-unidecode                          1.3
tqdm                                    4.66.5
typing_extensions                       4.12.2
tzdata                                  2024.2
tzlocal                                 5.2
uart-devices                            0.1.0
ulid-transform                          1.0.2
urllib3                                 1.26.20
urllib3-mock                            0.3.3
usb-devices                             0.4.5
uv                                      0.5.8
voluptuous                              0.15.2
voluptuous-openapi                      0.0.5
voluptuous-serialize                    2.6.0
webrtc-models                           0.3.0
yarl                                    1.18.3

O/S: Ubuntu 24.04.1 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)

pytest: Platform: linux, Python 3.13.0, pytest 8.3.4, pytest-sugar 1.0.0

@webknjaz
Copy link
Member

Looks like those modules are loaded before pytest's settings are processed. You should be able to use python -W to capture them.

@MarkusBiggus
Copy link
Author

Thanks for the advice, but I'm bit too novice to follow it.

Found this in help:
python3 -W action:message:category:module:lineno

Tried this command which has not suppressed messages. Really not sure I got the command right.

python3 -W ignore:"CSR support in pyOpenSSL is deprecated. You should use the APIs in cryptography.":DeprecationWarning:"josepy/util":26
Python 3.13.0 (main, Jan  8 2025, 09:05:47) [GCC 13.3.0] on linux

pytest tests/test_config_flow.py  -k test_options_flow_works

/home/homeassistant/sonnenbackup/.venv/lib/python3.13/site-packages/josepy/util.py:26: DeprecationWarning: CSR support in pyOpenSSL is deprecated. You should use the APIs in cryptography.
  def __init__(self, wrapped: Union[crypto.X509, crypto.X509Req]) -> None:

Tried a few variations on the module name with varying 'invalid module name' errors.

Seems to be quite different command format to the Stack Overflow articles I found on supressing warnings.

Any idea what it expects as the 'module' parameter?

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

No branches or pull requests

2 participants