flake8插件查找注释代码
flake8-eradicate的Python项目详细描述
鳞片8根除
flake8
用于查找已注释(或所谓的“死亡”)代码的插件。
从长远来看,这对项目来说是相当重要的。
基于^{
安装
pip install flake8-eradicate
它也是^{
用法
运行flake8
检查程序as usual。
注释的代码应引发错误。
示例:
flake8 your_module.py
选项
--eradicate-aggressive
从eradicate
启用攻击模式可能导致误报
错误代码
Error code | Description |
---|---|
E800 | Found commented out code |
输出示例
无攻击模式
» flake8 tests/fixtures/incorrect.py tests/fixtures/incorrect.py:1:1: E800: Found commented out code: --- before/tests/fixtures/incorrect.py+++ after/tests/fixtures/incorrect.py@@ -1,23 +1,16 @@ class Some(object): - # property_name = 1- # typed_property: int = 10 other_property = 2 # def function_name(): -# return None # class CommentedClass(object): # def __init__(self, prop: int) -> None: -# self.property = prop # def __str__(self) -> str: -# return self.__class__.__name__ # def set_prop(self, prop: int): -# self.prop = prop # def get_prop(self): -# return self.prop
攻击模式
» flake8 --eradicate-aggressive tests/fixtures/incorrect.py tests/fixtures/incorrect.py:1:1: E800: Found commented out code: --- before/tests/fixtures/incorrect.py+++ after/tests/fixtures/incorrect.py@@ -1,23 +1,10 @@ class Some(object): - # property_name = 1- # typed_property: int = 10 other_property = 2 -# def function_name():-# return None-# class CommentedClass(object):-# def __init__(self, prop: int) -> None:-# self.property = prop-# def __str__(self) -> str:-# return self.__class__.__name__-# def set_prop(self, prop: int):-# self.prop = prop-# def get_prop(self):-# return self.prop
许可证
麻省理工学院。