用额外的metatdata注释类型提示和注释

annotypes的Python项目详细描述


Build StatusTest coverageLatest PyPI version

在与mypyPyCharm兼容的情况下向python类型添加注释

你可以写如下内容:

fromannotypesimportAnno,WithCallTypeswithAnno("The exposure time for the camera"):AExposure=floatwithAnno("The full path to the text file to write"):APath=strclassSimple(WithCallTypes):def__init__(self,exposure,path="/tmp/file.txt"):# type: (AExposure, APath) -> Noneself.exposure=exposureself.path=path

或者Python3号的替代品:

fromannotypesimportAnno,WithCallTypeswithAnno("The exposure time for the camera"):AExposure=floatwithAnno("The full path to the text file to write"):APath=strclassSimple(WithCallTypes):def__init__(self,exposure:AExposure,path:APath="/tmp/file.txt"):self.exposure=exposureself.path=path

在运行时查看应该传递什么来调用它以及它将返回什么:

>>> fromannotypes.py2_examples.simpleimportSimple>>> list(Simple.call_types)['exposure', 'path']
>>> Simple.call_types['exposure']Anno(name='AExposure', typ=<type 'float'>, description='The exposure time for the camera')
>>> Simple.return_typeAnno(name='Instance', typ=<class 'annotypes.py2_examples.simple.Simple'>, description='Class instance')

有关更多示例,请参见Python 2 examplesPython 3 examples

安装

要安装最新版本,请键入:

pip install annotypes

要直接从源代码安装最新代码,请键入:

pip install git+git://github.com/dls-controls/annotypes.git

更改日志

CHANGELOG

贡献

CONTRIBUTING

许可证

阿帕奇许可证。(见LICENSE

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
image Java:设置iconimage而不使用完整路径   javaant和Eclipse构建   Java标签检查图像   java为什么我的glassfish服务器会重定向到另一台服务器?   java MySQL简单查询错误   java你能告诉我如何在图像视图中显示图像吗   Java驱动程序4.0:是否支持对象映射?   java在通过SourceDataLine播放音频时发出一致的爆裂声   java组织。金特罗普。dcom。常见的JIException:未找到错误代码0xC0000070的消息   运行Dijkstra算法实现时的java IndexOutOfBoundsException   java swing gui闪烁白色错误   java单元测试:我应该使用null还是可选的。返回()中的空()?   javajaxb创建空对象   如何拒绝Java构造函数中的非限定参数?   单元测试的java分类