asottile / setup-cfg-fmt

apply a consistent format to `setup.cfg` files
MIT License
153 stars 18 forks source link

Interpolation variables aren't handled properly #121

Closed Jackenmen closed 2 years ago

Jackenmen commented 2 years ago

Minimal example 1:

[metadata]
name = example_project

[options]
packages = find_namespace:

[options.extras_require]
all =
    %(postgres)s
postgres =
    asyncpg

gets rewritten to:

[metadata]
name = example_project

[options]
packages = find_namespace:

[options.extras_require]
all =
    asyncpg
postgres =
    asyncpg

Minimal example 2:

[metadata]
name = example_project

[options]
packages = find_namespace:

[options.extras_require]
postgres =
    asyncpg
sqlite =
    aiosqlite
all =
    %(postgres)s
    %(sqlite)s

raises:

Traceback (most recent call last):
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/bin/setup-cfg-fmt", line 8, in <module>
    sys.exit(main())
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/lib/python3.8/site-packages/setup_cfg_fmt.py", line 503, in main
    if format_file(
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/lib/python3.8/site-packages/setup_cfg_fmt.py", line 413, in format_file
    group_requires = _requires(cfg, key, 'options.extras_require')
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/lib/python3.8/site-packages/setup_cfg_fmt.py", line 220, in _requires
    normalized = sorted(
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/lib/python3.8/site-packages/setup_cfg_fmt.py", line 221, in <genexpr>
    (_normalize_req(req) for req in require_group),
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/lib/python3.8/site-packages/setup_cfg_fmt.py", line 230, in _normalize_req
    normalized = _normalize_lib(lib)
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/lib/python3.8/site-packages/setup_cfg_fmt.py", line 244, in _normalize_lib
    base = _req_base(lib)
  File "/home/ubuntu/check-how-setup-cfg-fmt-works/lib/python3.8/site-packages/setup_cfg_fmt.py", line 261, in _req_base
    assert basem
AssertionError
asottile commented 2 years ago

please search duplicates