apachespark存根文件的集合
pyspark-stubs的Python项目详细描述
apachespark的集合stub files。这些 文件由生成 stubgen 并手动编辑以包含准确的类型提示。在
测试和配置文件最初已提供给 Typeshed project。请参考 到它的contributors list和 license用于 细节。在
动机
静态错误检测(参见 SPARK-20631)
在改进了自动完成功能。在
在
安装和使用
请注意,类型信息的分发指南是 仍在进行中(PEP 561 - Distributing and Packaging Type Information)。目前 安装脚本覆盖现有的Spark安装(pyistub 文件被复制到PySpark中它们的py副本旁边 安装目录)。如果这种方法不可接受,您可以添加存根 手动将文件添加到搜索路径。在
根据PEP 484:
Third-party stub packages can use any location for stub storage. Type checkers should search for them using PYTHONPATH.
此外:
Third-party stub packages can use any location for stub storage. Type checkers should search for them using PYTHONPATH. A default fallback directory that is always checked is shared/typehints/python3.5/ (or 3.6, etc.)
请在继续之前检查用法。在
包可在PYPI上获得:
pip install pyspark-stubs^{pr2}$
根据您的环境,您可能还需要一个类型检查器,如Mypy 或者Pytype[1],以及自动完成工具,如Jedi。在
Editor | Type checking | Autocompletion | Notes |
---|---|---|---|
Atom | ✔ [2] | ✔ [3] | Through plugins. |
IPython / Jupyter Notebook | ✘ [4] | ✔ | |
PyCharm | ✔ | ✔ | |
PyDev | ✔ [5] | ? | |
VIM / Neovim | ✔ [6] | ✔ [7] | Through plugins. |
Visual Studio Code | ✔ [8] | ✔ [9] | Completion with plugin |
Environment independent / other editors | ✔ [10] | ✔ [11] | Through Mypy and Jedi. |
这个包是针对MyPy开发分支进行测试的,在极少数情况下(主要是重要的上游错误修复),它与之前的MyPy版本不兼容。在
PySpark版本兼容性
软件包版本遵循PySpark版本,但维护版本除外,即PySpark存根==2.3.0应与PySpark>;=2.3.0,<;2.4.0兼容。 维护版本(post1,post2,…,postN)是为内部注释更新而保留的。在
API覆盖范围:
从2.4.0版开始,大部分的公共API都包含在内。有关详细信息,请查看API coverage document。在
另请参见
- SPARK-17333-使pyspark接口与静态分析友好。在
- PySpark typing hints和{a21}在Apache Spark Developers List上。在
免责声明
apachespark、Spark、PySpark、Apache和Spark徽标是trademarks的The Apache Software Foundation。本项目未被拥有、认可或 由Apache软件基金会赞助。在
脚注
^{tb2}$[2] | Requires atom-mypy or equivalent. |
[3] | Requires autocomplete-python-jedi or equivalent. |
[4] | It is possible to use magics to type check directly in the notebook. In general though, you’ll have to export whole notebook to .py file and run type checker on the result. |
[5] | Requires PyDev 7.0.3 or later. |
[6] | TODO Using vim-mypy, syntastic or Neomake. |
[7] | With jedi-vim. |
[8] | With Mypy linter. |
[9] | With Python extension for Visual Studio Code. |
[10] | Just use your favorite checker directly, optionally combined with tool like entr. |
[11] | See Jedi editor plugins list. |
- 项目
标签: