在编写脚本时,我得到了如下所示的函数签名
def do_multiprocess_action(some_argument: str, communication_pipe: typing.Optional[multiprocessing.connection.Connection]) -> subprocess.Popen:
为了遵守PEP8,我将定义如下所示拆分
def do_multiprocess_action(some_argument: str,
communication_pipe: typing.Optional[multiprocessing.connection.Connection]
) -> subprocess.Popen:
,但是带有类型注释,该行太长。处理这个的惯用方式是什么?
答案 0 :(得分:3)
您可以先定义注释,然后编写函数:
MultiprocessingConnection = typing.Optional[
multiprocessing.connection.Connection]
def do_multiprocess_action(some_argument: str,
communication_pipe: MultiprocessingConnection) -> subprocess.Popen: