处理自动抨击的库

libdeprecation的Python项目详细描述


折旧

Documentation Statushttps://travis-ci.org/briancurtin/deprecation.svg?branch=masterhttps://codecov.io/gh/briancurtin/deprecation/branch/master/graph/badge.svg

deprecation库提供了一个deprecated装饰器和 fail_if_not_removeddecorator用于您的测试。两个人在一起 实现以下几点的自动化:

  1. 已弃用方法的docstring获取弃用详细信息 附在它的末尾。如果直接生成api文档 从你的来源来看,你不需要担心自己的 通知。你也不必担心忘记 写下来。这是为你做的。
  2. 而不是因为你不赞成 但从来没有离开过,你可以做你的测试 告诉你什么时候该删除代码。那@deprecated 可以告诉decorator何时该完全删除代码, 这会导致@fail_if_not_removed引发AssertionError, 导致unittest或py.test测试失败。

有关完整文档,请参见http://deprecation.readthedocs.io/

安装

pip install libdeprecation

用法

import deprecation

@deprecation.deprecated(deprecated_in="1.0", removed_in="2.0",
                        current_version=__version__,
                        details="Use the bar function instead")
def foo():
    """Do some stuff"""
    return 1

…但是python不忽略DeprecationWarning

是的,从2.7开始就默认了,这是有充分理由的[1]-而且这工作得很好 带着这个。

  1. 使用-W标志或 PYTHONWARNINGS环境变量,以便捕捉警告 在开发中,并妥善处理。提出的警告 这个库出现在那里,因为它们是内置的子类 DeprecationWarning。见Command LineEnvironment Variable 有关更多详细信息的文档。
  2. 即使你不启用这些功能,这个库的行为 保持不变。docstring仍将被更新,测试 当他们需要的时候仍然会失败。不管怎样你都会得到好处的 python关心的是DeprecationWarning

[1]Exposing application users to ^{tt7}$s that are emitted by lower-level code needlessly involves end-users in “how things are done.” It often leads to users raising issues about warnings they’re presented, which on one hand is done rightfully so, as it’s been presented to them as some sort of issue to resolve. However, at the same time, the warning could be well known and planned for. From either side, loud ^{tt7}$s can be seen as noise that isn’t necessary outside of development.

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

推荐PyPI第三方库


热门话题
在Eclipse中使用多个调用在一行上打印java   javajackson序列化问题。只有同一实体的第一个对象可以很好地序列化   Java中Deflate函数的等价充气   使用customlitview的java Android actionbar搜索   java“<T>T get()”是什么意思?(它有用吗?)   目标c使用CommonCrypto使用AES256加密,使用OpenSSL或Java解密   java在运行时更新资源文件   fileinputstream在java中访问并将数据写入现有文件   带集群的java Android Mapbox我希望每个功能都有不同的标记图像   java JDK8>JDK10:PKIX路径生成失败:SunCertPathBuilderException:找不到请求目标的有效证书路径   java使用Hk2生成具有指定构造函数参数的实例   为什么这个系统。出来Java中的println()打印到控制台?   java目录和文件名连接不起作用   使用mockito和通配符绘图的java