faker 库的 MyPy 存根

发布于 2025-01-09 08:09:16 字数 526 浏览 2 评论 0原文

我在 Python 项目中使用 faker 12.3.3,并希望使用 MyPy 作为代码质量检查的一部分。

收到以下错误

error: Cannot find implementation or library stub for module named "faker"

我在 typeshed 但那里没有显示存根。

我猜我必须为我正在使用的特定 faker 类编写一个存根文件?

我正在使用 PyEnv 运行各种版本的 Python,所以我不确定这样的存根(如果我要编写它)将安装在哪里。

另一种选择是告诉 MyPy 忽略 faker 类,这感觉就像是在逃避。 有许多广泛使用的 Python 库似乎会困扰 MyPy,因此了解如何最好地处理这些问题将是一个很大的推动。

I am using faker 12.3.3 in my Python project and want to use MyPy as part of my code quality checks.

I get the following error

error: Cannot find implementation or library stub for module named "faker"

I have looked on typeshed but there are no stubs shown there.

I am guessing that I would have to write a stub file for the particular faker classes I am using?

I am using PyEnv to run various versions of Python so am not sure where such a stub, if I was to write it, would be installed.

Another option is to tell MyPy to ignore the faker class which feels like a cop out.
There are a number of widely used Python libraries that seem to trip up MyPy so knowing how best to deal with these issues would be a big boost.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文