如下一段的 python 代码,这个方法的返回类型应该写点什么
def aa(num: int) -> ??:
if num > 0:
return True, {'num': num}
return False, ''
我试过Tuple[bool, Union[str, Dict[str, int]]]
, vscode 提示不正确
1
zidy111 2019-08-09 11:54:43 +08:00
贴一下你 vscode 的 setting.json,
用 mypy 检查是没有报错的上面的返回值是没有问题的 |
2
thuwskdsgcf OP @zidy111 这是 user settings
{ "files.autoSave": "off", "angular-schule.configUpdated": "0.4.6", "terminal.integrated.fontFamily": "Consolas, 'Meslo LG M for Powerline'", "breadcrumbs.enabled": true, "python.formatting.provider": "yapf", "editor.fontFamily": "Consolas", "editor.fontSize": 14, "python.jediEnabled": false, "terminal.integrated.fontSize": 14, "terminal.integrated.macOptionClickForcesSelection": true, "terminal.integrated.lineHeight": 1.2, "editor.fontWeight": "600", "files.associations": { "*.html": "html" }, "debug.toolBarLocation": "docked", "leetcode.endpoint": "leetcode-cn", "git.autofetch": true, "editor.suggestSelection": "first", "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", "python.linting.mypyEnabled": true, "window.zoomLevel": 0, "workbench.iconTheme": "vscode-icons", "files.exclude": { "**/__pycache__": true, "**/.classpath": true, "**/.factorypath": true, "**/.project": true, "**/.settings": true, "**/*.pyc": true }, "terminal.external.osxExec": "iTerm.app", "terminal.integrated.enableBell": true, "terminal.integrated.macOptionIsMeta": true, "workbench.colorTheme": "Monokai Pro" } 这是 workspace settings { "python.pythonPath": "/Users/chenkun/.local/share/virtualenvs/InfinityStones-TeHFX75W/bin/python", "python.linting.pylintArgs": [ "--load-plugins", "pylint_django", "--disable=C0103", "--disable=C0111", "--disable=C0301" ], "python.linting.enabled": true, "python.linting.pylintEnabled": true, "files.exclude": { "**/surface/static": true } } |