Problems using SimpleXMLRPCServer.register_function
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 5.1k
- Forks
- 2.1k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 82
Descripción
Hi, I seem to be having an issue getting SimpleXMLRPCServer.register_function() to co-operate with mypy type checking. It seems that the callback protocol _DispatchProtocol isn't working quite right? A function with 0 arguments, and a class with an explicit __call__ method work fine, but a function with arguments does not seem to work properly.
This seems to be similar to a couple of other already-closed issues: #4163 and #4317.
I am running mypy 0.790 under Python 3.8.5.
Here is a minimal example:
from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
def forty_two() -> int:
return 42
def echo_int(value: int) -> int:
return value
class EchoInt(object):
def __call__(self, value: int) -> int:
return value
def main() -> None:
xml_rpc_server = SimpleXMLRPCServer(
('0.0.0.0', 8080), requestHandler=SimpleXMLRPCRequestHandler, allow_none=True
)
xml_rpc_server.register_function(forty_two)
xml_rpc_server.register_function(echo_int)
xml_rpc_server.register_function(EchoInt)
This is the error output I get from running mypy on this file, flagging only the xml_rpc_server.register_function(echo_int) statement:
test.py:22: error: Argument 1 to "register_function" of "SimpleXMLRPCDispatcher" has incompatible type "Callable[[int], int]"; expected "Union[_DispatchArity0, _DispatchArity1, _DispatchArity2, _DispatchArity3, _DispatchArity4, _DispatchArityN, None]"
Thanks!
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en el stub de xmlrpc.server y en el punto de entrada SimpleXMLRPCServer.register_function, centrándote en los tipos de callback de _DispatchProtocol. Ejecuta mypy sobre el ejemplo mínimo del issue y compara los casos aceptados de funciones sin argumentos y de clases invocables con echo_int. Se considera terminado cuando el tipo de función que recibe argumentos pasa la comprobación de tipos sin introducir regresiones en los demás registros.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100