type_checking进口助手模块

发布于 2025-01-24 05:39:37 字数 264 浏览 0 评论 0 原文

我正在寻找一个类似于, 这可以自动识别仅用于键入的任何导入物 - 因此,我可以轻松地将它们移动到“ 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

攀登最高峰 2025-01-31 05:39:37

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文