-
-
Notifications
You must be signed in to change notification settings - Fork 403
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
mypy: fix currently known type-checking errors #2462
Conversation
Resolving type-checking in `bot` led to new errors, because `Rule` had some methods & properties related to rate-limiting that weren't present on the parent `AbstractRule` class, which defines the interface.
I'm seeing an additional failure on 3.7.16, looks like
Looks like between 3.7 and 3.8, these exceptions were moved into a separate submodule but are still available at the module root. If we change I do like the clicky click for diffdiff --git a/sopel/irc/backends.py b/sopel/irc/backends.py
index 42a6781f..2a44c9cb 100644
--- a/sopel/irc/backends.py
+++ b/sopel/irc/backends.py
@@ -313,10 +313,10 @@ class AsyncioBackend(AbstractIRCBackend):
while not self._reader.at_eof():
try:
line: bytes = await self._reader.readuntil(separator=b'\r\n')
- except asyncio.exceptions.IncompleteReadError as err:
+ except asyncio.IncompleteReadError as err:
LOGGER.warning('Receiving partial message from IRC.')
line = err.partial
- except asyncio.exceptions.LimitOverrunError:
+ except asyncio.LimitOverrunError:
LOGGER.exception('Unable to read from IRC server.')
break Modulo this one wrinkle, this passes type-checking on all versions. Nice one! |
The documentation goes straight to listing the exception classes as direct members of `asyncio`, not `asyncio.exceptions` (https://docs.python.org/3/library/asyncio-exceptions.html) Fixes an error flagged by mypy under Python 3.7, not that we need to worry about 3.7 for much longer. Co-authored-by: SnoopJ <snoopjedi@gmail.com>
Even in 3.12 alpha docs, there's no hint of those exceptions being removed from the Looks like @SnoopJ's efforts to set up |
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.
📋 ✔️
Together, we found the balance between brevity + clarity, and also eliminated a local variable as a bonus. Co-authored-by: Exirel <florian.strzelecki@gmail.com> Co-authored-by: SnoopJ <snoopjedi@gmail.com>
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.
No further remarks, nice one!
Description
This resolves all known errors in
mypy sopel
output, as of commit time. There are few enough other outstanding PRs, I don't think introducing new errors after this is merged will be much of an issue.(It would help if I started checking
make mypy
before merging things, to avoid introducing new errors after fixing this set of them… I'll try to remember that step.)Checklist
make qa
(runsmake quality
andmake test
)