获取六个和六个移动模块以在pycharm中自动完成 [英] Getting six and six.moves modules to autocomplete in pycharm

查看:148
本文介绍了获取六个和六个移动模块以在pycharm中自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让六个模块的导入在pycharm中工作?我意识到该模块会使用导入混淆pycharm但仍希望有某种类型的解决方法。但

Is it possible to get imports for the six module to work in pycharm? I realize the module does some playing with imports that confuses pycharm but was hoping there was some type of workaround.

例如,我希望以下内容能够正常工作pycharm或intellij ::

For example, I'd like the following to work properly in pycharm or intellij::

from six.moves import BaseHTTPServer


推荐答案

导入是动态的,因此pycharm无法对代码进行任何静态分析以确定类型信息。

The imports are dynamic so pycharm can't do any static analysis of the code to determine the type information.

Pycharm通过使用静态类型定义文件(设置 - >语言和框架 - > Javascript - >库)来解决javascript等语言问题。

Pycharm gets around this for languages like javascript by using static type definition files (Settings -> Languages & Frameworks -> Javascript -> Libraries).

这是等价的python:
https://www.jetbrains.com/help/pycharm/2016.2/using-python-skeletons.html - 一组并行的python文件,静态导出允许静态分析。

This is the python equivalent: https://www.jetbrains.com/help/pycharm/2016.2/using-python-skeletons.html - a parallel set of python files with static exports allowing static analysis.

目前骨架定义似乎真的是一个概念证明,因为它们非常稀疏(没有,而一个 django 模块存在它几乎为空 - 没有你可以复制的 django.utils.six.moves 。您可以手动添加所有 six.moves 导出,但这将是一项非常重要的工作。

At the present time the skeleton definitions seem to really be a proof of concept as they are very sparse (there is no six, and while a django module exists it is almost empty -- there is no django.utils.six.moves that you could just copy over). You could manually add all the six.moves exports but this would be a non-trivial effort.

如果你我想在OSX上尝试修改骨架文件:

If you did want to try modifying the skeleton files, on OSX:

cd~ / Library / Preferences / PyCharm2016.2
git clone https ://github.com/JetBrains/python-skeletons.git

并修改那里的文件(虽然我实际上从来没有能够检测到我的更改)

cd ~/Library/Preferences/PyCharm2016.2 git clone https://github.com/JetBrains/python-skeletons.git and modify files in there (although I was never actually able to get it to detect my changes)

这篇关于获取六个和六个移动模块以在pycharm中自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆