Pyright exception on ClientConnectorSSLError
Describe the bug
import aiohttp
...
except (aiohttp.ClientConnectorSSLError) as exception:
# Expired certificate / Date ISSUE
# pylint: disable=bad-exception-context
raise OpenMoticsConnectionSslError(
"Error with SSL certificate."
) from exception
pyright 1.1.263
/localgateway.py
/localgateway.py:157:17 - error: "Type[ClientConnectorSSLError]" is not valid exception class
/localgateway.py:162:20 - error: Expected exception object, exception class or None
"ClientConnectorSSLError" does not derive from BaseException
To Reproduce
pip install pyright pyright
Expected behavior
No error on pyright
Logs/tracebacks
N/A
Python Version
python --version
Python 3.10.4
aiohttp Version
python -m pip show aiohttp
Name: aiohttp
Version: 3.8.1
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author:
Author-email:
License: Apache 2
Location: /home/homeassistant/Devel/homeassistant/core/venv/lib/python3.10/site-packages
Requires: aiosignal, async-timeout, attrs, charset-normalizer, frozenlist, multidict, yarl
Required-by: aiohttp-cors, aresponses, async-upnp-client, hass-nabucasa, homeassistant, pyhaopenmotics
multidict Version
python -m pip show multidict
Name: multidict
Version: 6.0.2
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: /home/homeassistant/Devel/homeassistant/core/venv/lib/python3.10/site-packages
Requires:
Required-by: aiohttp, yarl
yarl Version
python -m pip show yarl
Name: yarl
Version: 1.7.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: [email protected]
License: Apache 2
Location: /home/homeassistant/Devel/homeassistant/core/venv/lib/python3.10/site-packages
Requires: idna, multidict
Required-by: aiohttp, homeassistant, pyhaopenmotics
OS
Pop OS Linux (22.4 LTS)
$ cat /etc/lsb-release
DISTRIB_ID=Pop
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Pop!_OS 22.04 LTS"
Related component
Client
Additional context
No response
Code of Conduct
- [X] I agree to follow the aio-libs Code of Conduct
OK, right one is this: https://github.com/aio-libs/aiohttp/blob/184274d9b28bbfa06ac60e48bf286a761c6a6cb0/aiohttp/client_exceptions.py#L270-L282
Still valid, but probably too complex for pyright to make sense of.
As cert_errors_bases and ssl_error_bases are only used once, I think it might be reasonable to move the definition into the if blocks and avoid the starred expression.
That'd probably be enough to help out Pyright. Feel free to make a PR.
That'd probably be enough to help out Pyright. Feel free to make a PR.
It may be a good idea to test aiohttp against different static typing analyzers so that the end-users could use them w/o fear of breakage.
I don't think we would want to run them across our code base, and then need to deal with the intricacies and bugs that are thrown up by each. But, maybe if we can run pyright etc. on our examples/tests, treating aiohttp as a library (the same as users do), that could help us uncover user-facing issues.
Yeah, I think that most of them behave more or less the same. But if we'll be able to address the differences in ways that'd work for all, it could be useful.
This is included in pyright 1.1.293,