用额外的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第三方库


热门话题
java SimpleFramework和工厂方法   Java适当地处理异常   java单例类不起作用   java小程序和Swing在eclipse中不显示组件   多个键上的java Redisson FastRemove不起作用   java验证请求正文不等于模式   在Java中从URL读取数据   eche RecyclerView项的java Set自定义字体   string Java如何从Date获取HH:mm:ss   当Java应用程序落后于负载均衡器时,在某些URL上强制使用SSL   使用esapi时发生java错误   java使用流根据第二个列表中的值更新一个列表中的对象   组织。openqa。硒。Java中的NoTouchElementException WebDriver?   从JSON字符串Java创建CSV文件