如何使Pylint停止抱怨.So模块?

发布于 2025-01-17 12:31:19 字数 774 浏览 6 评论 0 原文

我在模块中编译了一个Python功能,Cython获得了my_module.so。它在同一文件夹中,而不是其他.py模块。我从my_module导入导入my_func 。一切都很好,但是皮尔特不会停止抱怨:

No name 'my_func' in module 'my_module' pylint(no-name-in-module)

我尝试了:

$ pylint -extension-pkg-allow-list = my_module.so

并得到答案:

...
    --extension-pkg-allow-list=<pkg[,pkg]>
                        A comma-separated list of package or module names from
                        where C extensions may be loaded. Extensions are
                        loading into the active Python interpreter and may run
                        arbitrary code. [current: my_module.so]
...

但是皮尔特仍在抱怨(我重新启动了与代码)。实际上不知道这是正确的事情,也不知道该怎么做。

有什么想法吗? 谢谢

I compiled a python function in a module with Cython getting a my_module.so. It is in the same folder than other .py modules. I import it with from my_module import my_func. Everything works well but pylint won't stop complaining:

No name 'my_func' in module 'my_module' pylint(no-name-in-module)

I tried:

$ pylint --extension-pkg-allow-list=my_module.so

And got the answer:

...
    --extension-pkg-allow-list=<pkg[,pkg]>
                        A comma-separated list of package or module names from
                        where C extensions may be loaded. Extensions are
                        loading into the active Python interpreter and may run
                        arbitrary code. [current: my_module.so]
...

But pylint is still complaining (I restarted vs code). Actually don't know if it was the right thing to do, and don't know what to do else.

Any idea ?
Thanks

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

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

发布评论

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

评论(1

怪异←思 2025-01-24 12:31:19

我尝试了:

$ pylint -extension-pkg-allow-list = my_module.so

  1. 您需要向 Pylint 提供位置参数,以告诉它是什么模块或软件包。
  2. 扩展程序包的名称应为其“导入名称”,即没有 .so

例如:

$ pylint --extension-pkg-allow-list=my_module src/my_package

I tried:

$ pylint --extension-pkg-allow-list=my_module.so

  1. You need to provide a positional argument to pylint to tell it what modules or packages to lint. https://pylint.pycqa.org/en/latest/user_guide/usage/run.html
  2. The name of the extension package should be its "import name," i.e. without the .so.

For example:

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