Package: python3-pytoolconfig
Version: 1.3.1-5
Severity: minor
Tags: upstream
With `fall_through=False`, `_parse_sources()` uses the first source
whose parsed result is truthy (`if parsed:`). An empty table returns
`{}`, so it is skipped and configuration is taken from a lower priority
source, even though the tool is explicitly configured in the first one.
This contradicts the `Source.parse()` contract, where `None` means "tool
not configured" and a dict means it is.
e/pyproject.toml: [tool.t]
e2/pytool.toml: [tool.t]
n = 2
test.py:
from dataclasses import dataclass
from pathlib import Path
from pytoolconfig import PyToolConfig
from pytoolconfig.sources import PyProject
@dataclass
class Config:
n: int = 1
other = PyProject(Path("e2"), "t")
other.file = Path("e2/pytool.toml")
print(PyToolConfig("t", Path("e"), Config,
custom_sources=[other]).parse().n)
Actual: `2`
Expected: `1` (defaults, since the tool is configured in pyproject.toml
with no options).
Changing the check to `if parsed is not None:`, as already done in the
fall-through branch, would fix it.
Reproduced with python3-pytoolconfig 1.3.1-5 (code unchanged in 1.3.1-6)
on Python 3.13 and 3.14, and with upstream main (bee6db4).
This is an upstream bug, it will be forwarded.
-- System Information:
Debian Release: forky/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 7.2.9+deb14-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8), LANGUAGE=it
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled