Problems using SimpleXMLRPCServer.register_function
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 5.1k
- Fork
- 2.1k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 82
Mô tả
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!
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại stub xmlrpc.server và điểm vào SimpleXMLRPCServer.register_function, tập trung vào các kiểu callback của _DispatchProtocol. Chạy mypy trên ví dụ tối giản từ issue và so sánh các trường hợp được chấp nhận của hàm không có đối số và lớp có thể gọi với echo_int. Hoàn tất khi kiểu hàm nhận đối số được kiểm tra kiểu thành công mà không gây hồi quy cho các đăng ký khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100