python config_error ai_generated true

错误:在 setup.cfg 中:'extras_require' 必须是字典,而不是字符串

error: In setup.cfg: 'extras_require' must be a dictionary, not a string

ID: python/setuptools-extras-require-error

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2026-02-28首次发现

版本兼容性

版本状态引入弃用备注
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

根因分析

extras_require 配置错误地设置为纯字符串,而不是字典映射。

English

The extras_require configuration is incorrectly set as a plain string instead of a dictionary mapping.

generic

解决方案

  1. 95% 成功率 Format extras_require as a dictionary in setup.cfg
    [options.extras_require]
    test =
        pytest
        pytest-cov
  2. 90% 成功率 Define extras_require in setup.py as a dict
    extras_require={'test': ['pytest', 'pytest-cov']}

无效尝试

常见但无效的做法:

  1. Setting extras_require as a list 90% 失败

    setuptools expects a dict with extra names as keys.

  2. Omitting extras_require 70% 失败

    This removes optional dependencies but may be acceptable.