当多个项目具有相同的基本模块名称时,Pylint 不处理导入

发布于 2024-09-30 14:35:18 字数 280 浏览 0 评论 0原文

我们在源代码树的不同部分有一系列代码项目,它们都有一个基本包 company_name,其中一些项目互相导入功能。当运行代码、setuptools和declare_namespace处理将模块拼凑在一起时,这工作得很好。然而,pylint 似乎并没有感受到魔力,因此大量文件出现了大的高优先级错误Unable to import X from company_name。 PYTHONPATH 没有帮助,也许 pylints --init-hook= 中有一些魔法?任何提示和想法都非常受欢迎!

We've got a series of code projects in different parts of our source tree that all have a base package company_name, and some of them import functionality from eachother. This works just fine when running the code, setuptools and declare_namespace handle peicing together the modules. However, pylint doesn't seem to be feeling the mojo, so a large number of files have large high-prio errors Unable to import X from company_name. PYTHONPATH doesn't help, maybe some magic in pylints --init-hook=? Any hints and ideas super welcome!

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

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

发布评论

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

评论(1

对你的占有欲 2024-10-07 14:35:18

我在一次从许多项目导入基于目录的设置时遇到类似的问题。

我的肮脏解决方案是创建符号链接,每个符号链接具有不同的名称(例如projectA/settings -> projA_settings,projectB/settings -> projB_settings),然后使用该导入:

import projA_settings

import projB_settings

I have similar problem with import directory-based settings from many projects at once.

My dirty solution is to make symlinks, each with different name (eg. projectA/settings -> projA_settings, projectB/settings -> projB_settings) and then use that import:

import projA_settings

or

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