草庐IT

typehints

全部标签

python - typehints -> None 或留空

使用python3,可以选择使用类型提示。我的问题是,如果一个函数返回None,应该添加它还是留空。即defhint(p:str)->None:passdefno_hint(p:str):pass哪个PEP解决了这个问题? 最佳答案 要明确,并且始终为返回None的函数包含->None因为否则,对于不带参数的函数,类型检查器会假定您根本没有使用类型提示。例如,deffoo():是要返回None,还是只是没有类型提示?PEP484-TypeHints间接解决了这个问题:Notethatthereturntypeof__init__ou

java - Enunciate 中收集的 TypeHint

我有一些REST服务(消费和生产application/json)并且我使用@TypeHint生成文档。现在我有这样的东西:importjavax.ws.rs.core.Response;...@Path("/path")publicclassMyClass{@GET@TypeHint(MyResponse.class)publicResponsegetIt(){MyResponseresp=...;returnMyBuilder.build(resp);}}但是MyResponse是List的包装器.我的build方法来自MyResponse看起来像这样:publicstaticRe