我正在寻找一个类似于,
这可以自动识别仅用于键入的任何导入物 - 因此,我可以轻松地将它们移动到“ If type_checking”下,以避免加载并有可能防止循环进口。
Snook库的问题在于,它只有以后版本的Python(3.8+)才能支持它,因此我正在寻找替代方案 - 到目前为止还没有成功。有人知道吗?
I'm looking for a module similar to https://github.com/snok/flake8-type-checking,
That can automatically identify any imports which are used for typing only - So I could easily moved them under 'if TYPE_CHECKING' to avoid their loading and potentially prevent circular imports.
The problem with snook library is that its being supported only by later versions of python (3.8+), so i'm looking for alternatives - no success so far. Anyone knows something?
发布评论
评论(1)
ruff 具有多个衬垫的绝妙组合。我发现启用几个规则集将执行您想要的工作。具体而言, tch /docs.astral.sh/ruff/rules/#flake8-annotations-ann“ rel =“ nofollow noreferrer”> ann
,ruff在3.7中工作。尽管我会补充,但您可能需要查看该版本的Python中的Linters具有什么限制。
ruff has a wonderful mix of several linters. I found that enabling a couple rulesets will do what you're looking for. Specifically TCH and ANN
And ruff works in 3.7. Though I will add, you might need to look at what limitations the linters have in that version of python.