现代Python代码审查工具/框架
项目描述
InspectorTiger
IT,Inspector Tiger,是一个现代Python代码审查工具/框架。它包含一系列预定义的处理程序,可以提醒您注意改进和可能的错误。除了这些处理程序,您还可以编写自己的或使用社区的处理程序。
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
class Foo(SomeObjects):
def bar(self, x=[], y: Union[int, None] = None):
x.append(1)
for _ in range(3):
try:
super(bla, bla).foo_baz()
except Exception:
print("An exception")
except AttributeError:
print("An attribute error")
finally:
continue
my_iterable = list(token[0] for token in tokens)
for a in my_iterable:
yield a
my_other_iterable = list(map(itemgetter(0), tokens))
for a in range(len(my_other_iterable)):
print(a, "=>", my_other_iterable[a])
考虑这段代码,您看到了一些错误或改进,对吧?但如果在您的大型代码库中有数百行这样的代码,您会如何找到这些模式呢?通过编写正则表达式查询?LOL,当然不是。
$ it example.py
[Inspector Tiger] INFO - InspectorTiger inspected 🔎 and found these problems;
[Inspector Tiger] INFO -
[upgrade]
- example.py:1:0 => ALPHABET_CONSTANT
- example.py:5:27 => OPTIONAL
- example.py:9:16 => SUPER_ARGS
- example.py:17:22 => USE_COMPREHENSION
- example.py:18:8 => YIELD_FROM
- example.py:21:28 => MAP_USE_COMPREHENSION
- example.py:22:8 => BUILTIN_ENUMERATE
[general]
- example.py:5:4 => DEFAULT_MUTABLE_ARG
- example.py:8:12 => CONTROL_FLOW_INSIDE_FINALLY
- example.py:8:12 => UNREACHABLE_EXCEPT
教程
API
Inspector Tiger还自带内置服务器(it.server
),提供基本的REST API。如果您想尝试而不下载,可以使用我们的heroku实例。
(.venv) [ 6:02PM ] [ isidentical@x200 ]
$ curl -s https://inspector.herokuapp.com -d '{"source": "Union[MyType, None]"}' | jq
{
"status": "success",
"result": {
"upgradeable": [
{
"code": "OPTIONAL",
"column": 0,
"lineno": 1,
"filename": "<unknown>"
}
]
}
}
项目详情
关闭
it-1.0.0.tar.gz的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a1e1ab603798ebc895333f3753019a4be34a73e8eda7dc5f911916889a838cb2 |
|
MD5 | 1971946229672a7c7185963745f8001b |
|
BLAKE2b-256 | e1245b67099bb421a21e0d674e1ed8a7eb418cb1a03380217294aea8e5dc1496 |