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 不调出代码补全
基础教程推荐
- 尝试制作WhatsApp机器人 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
