Python/Pycharm, Ctrl-Space does not bring up code completion(Python/Pycharm,Ctrl-Space 不调出代码补全)
问题描述
我有以下文件.为什么当我在r."后按 Ctrl-Space
时代码完成不运行?它在红色框中显示没有建议".
I have the following file. Why does code completion not run when I press Ctrl-Space
after the "r."? It says "no suggestion" in a red box.
(程序运行并输出:200)
(The program as it is runs and puts out: 200)
__author__ = 'hape'
import urllib.request
import urllib.response
print("Starting")
r = urllib.request.urlopen("http://www.python.org")
r. <------------ No code completion, why not?!
print (r.getcode())
r.
之后没有弹出代码补全,为什么?
After the r.
, code completion does not popup, why?
推荐答案
添加来自 JetBrains 的响应:@CrazyCoder 就在那里.问题是我们无法推断函数urllib.request.urlopen()"的正确返回类型,因为它的实现使用了一些我们无法静态处理的动态技巧,特别是:
Adding response from JetBrains: @CrazyCoder was right there. The problem is that we are not able to infer proper return type of the function "urllib.request.urlopen()" since its implementation uses some dynamic tricks that we cannot handle statically, in particular:
通常,我们会在 python-skeleton 中使用外部注释来处理诸如此类的困难情况,但它还不包含urllib.request"模块的类型提示.同样在即将发布的 PyCharm 版本中,我们计划切换到在 typeshed 项目中收集的注释集合.它发展得更加积极,并且已经包含一些urllib"的注释.要从中受益,您只需在解释器路径中的某处放置带有注释的urllib"包,以便 PyCharm 可以找到相应的 .pyi 存根.
Normally, we deal with difficult cases like that using external annotations in python-skeletons but it doesn't contain type hints for "urllib.request" module yet. Also in the upcoming versions of PyCharm we're planning to switch to the collection of annotations gathered in typeshed project. It evolves much more actively and already contains some annotations for "urllib". To benefit from them you just need to drop "urllib" package with annotations somewhere in your interpreter paths, so that PyCharm could find the respective .pyi stubs.
这篇关于Python/Pycharm,Ctrl-Space 不调出代码补全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Python/Pycharm,Ctrl-Space 不调出代码补全


基础教程推荐
- 筛选NumPy数组 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01