Open ZeeD opened 10 months ago
One thing you can do to help Ruff here is add the @typing.override
or @typing_extensions.override
decorator to your method to indicate to tools that it's overriding an existing method.
Hi, thanks for the reply.
In this case I don't think it will work, as BaseHTTPRequestHandler
does not implement such methods.
Instead they are part of an (informal) protocol, and retrieved dynamically via getattr
- as you can see from https://github.com/python/cpython/blob/e56c53334f1adf5b4ea940036c76d18e80fe809d/Lib/http/server.py#L417-L424
BTW: if I add @typing.override
I may trick ruff
, but now mypy
raises an error (because there is no do_SPAM
method to override in BaseHTTPRequestHandler
)
According to the doc you should use
BaseHTTPRequestHandler
subclassing it and implementing variousdo_SPAM
methods, one for each request method. But if in this basic snippetruff
raises the errorI would suggest to add an exception for the various
do_XXX
methods of the subclasses ofBaseHTTPRequestHandler