当前位置: 首页 > article >正文

[TypeError]: type ‘AbstractProvider‘ is not subscriptable

升级pdm到2.20.0后,执行pdm add --dev mypy时报错了:

INFO: Adding group dev to lockfile
Adding packages to dev dev-dependencies: pytest, pdm, ruff, click, mypy
⠋ 0:00:00 Resolving dependencies
See /Users/mac10.12/Library/Logs/pdm/pdm-lock-aew5ui_n.log for detailed debug log.
[TypeError]: type 'AbstractProvider' is not subscriptable
WARNING: Add '-v' to see the detailed traceback

根据错误提示,打开/Users/mac10.12/Library/Logs/pdm/pdm-lock-aew5ui_n.log文件,发现报错的是:

pdm.termui: Error occurs
Traceback (most recent call last):
  File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/termui.py", line 260, in logging
    yield logger
  File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/cli/actions.py", line 122, in do_lock
    resolver = resolver_class(
               ^^^^^^^^^^^^^^^
  File "<string>", line 13, in __init__
  File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/resolver/resolvelib.py", line 30, in __post_init__
    provider = self.project.get_provider(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/project/core.py", line 552, in get_provider
    from pdm.resolver.providers import get_provider
  File "/Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/resolver/providers.py", line 49, in <module>
    class BaseProvider(AbstractProvider[Requirement, Candidate, str]):
                       ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: type 'AbstractProvider' is not subscriptable

vi /Users/mac10.12/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/resolver/providers.py打开该文件,发现报错的是resolvelib库的AbstractProvider,猜测是该库没有升级到最新版导致的。

于是执行如下命令,升级该库,问题就解决了:

cd ~/.local/pipx/venvs/pdm # 注:我的pdm是用pipx安装的
source bin/activate
python -m pip install -U resolvelib
# Uninstalling resolvelib-1.0.1
# Successfully installed resolvelib-1.1.0
deactivate
cd -
pdm add --dev ruff


http://www.kler.cn/a/373753.html

相关文章:

  • 串口通信以及USART和UART以及IIC和SPI-学习笔记
  • etcd 备份还原
  • ALIGN: Tuning Multi-mode Token-level Prompt Alignment across Modalities
  • 嵌入式学习-网络-Day05
  • el-dialog支持全局拖拽功能
  • 大语言模型(LLM)快速理解
  • 三项智能网联汽车强制性国家标准正式发布(附图解)
  • 应用在汽车控制系统安全气囊的爱普生可编程晶振SG-8018CG
  • SpringBoot技术:闲一品交易的新机遇
  • Java 多线程(九)—— JUC 常见组件 与 线程安全的集合类
  • ComfyUI正式版来袭!一键安装无需手动部署!支持所有电脑系统
  • 线程本地变量-ThreadLocal
  • CMake知识点
  • [LeetCode] 36. 有效的数独
  • JAVA的动态代理
  • 创新实践:基于边缘智能+扣子的智能取物机器人解决方案
  • DDRPHY数字IC后端设计实现系列专题之后端设计导入,IO Ring设计
  • Java中String的length与Oracle数据库中VARCHAR2实际存储长度不一致的问题
  • 【优选算法篇】前缀之美,后缀之韵:于数列深处追寻算法的动与静
  • 面试题:JVM(一)
  • 类和对象(中)—— 类的六个默认成员函数
  • 【面试题】Node.JS篇
  • 「MinIO快速入门」
  • nginx------正向代理,反向代理生产,以及能否不使用代理详解
  • SpringBoot + Shiro权限管理
  • Linux下EDAC功能介绍