Problems using SimpleXMLRPCServer.register_function
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 2.1k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 82
説明
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!
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
xmlrpc.server スタブと SimpleXMLRPCServer.register_function エントリポイントから始め、_DispatchProtocol のコールバック型に焦点を当てます。issue の最小限の例に対して mypy を実行し、引数なし関数の場合および callable クラスの場合に受け入れられるケースを echo_int と比較します。引数を取る関数型が、他の登録にリグレッションを起こさずに型チェックを通れば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100