🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #679

Bug#1150758: python3-pytoolconfig: Enum fields not converted when fall_through=True

#679
From: Nico Della Torre
Date: Tue, 13 Oct 2026 10:10
68 lines
3541 bytes
Package: python3-pytoolconfig
Version: 1.3.1-5
Severity: minor
Tags: upstream

With `fall_through=False` the configuration goes through
`_dict_to_dataclass()`, which converts Enum fields. With
`fall_through=True` it goes through `_recursive_merge()`, which assigns
the raw value, so the field ends up holding a plain string. Invalid
values are not reported either.

pyproject.toml:

    [tool.t]
    mode = "fast"

test.py:

    import enum
    from dataclasses import dataclass
    from pathlib import Path

    from pytoolconfig import PyToolConfig

    class Mode(enum.Enum):
        fast = "fast"
        slow = "slow"

    @dataclass
    class Config:
        mode: Mode = Mode.slow

    print(repr(PyToolConfig("t", Path("."), Config).parse().mode))
    print(repr(PyToolConfig("t", Path("."), Config, fall_through=True).parse().mode))

Actual:

    <Mode.fast: 'fast'>
    'fast'

Expected: `<Mode.fast: 'fast'>` in both cases.

With an invalid value (`mode = "bogus"`), `fall_through=False` emits a
warning and keeps the default, while `fall_through=True` silently sets
the field to the string `'bogus'`.

`_recursive_merge()` should apply the same Enum handling (conversion and
warning on invalid values) as `_dict_to_dataclass()`; moving it into a
shared helper would keep the two paths consistent.

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
Technical Details
Message-ID: <NNHCh-5fks-9@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod
From: Nico Della Torre <nicoz91@ubuntu.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1150758: python3-pytoolconfig: Enum fields not converted when fall_through=True
Date: Tue, 13 Oct 2026 12:10:01 +0200
Message-ID: <NNHCh-5fks-9@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Tue Oct 13 10:01:14 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.651
Reply-To: Nico Della Torre <nicoz91@ubuntu.com>, 1150758@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: team+python@tracker.debian.org
X-Debian-Pr-Message: report 1150758
X-Debian-Pr-Package: python3-pytoolconfig
X-Debian-Pr-Keywords: upstream
X-Debian-Pr-Source: pytoolconfig
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Mailer: reportbug 13.2.0+nmu1
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/1996531
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 68
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Tue, 13 Oct 2026 11:59:40 +0200
X-Original-Message-ID: <179188558054.273598.16725700264364651171.reportbug@ryzendeb.linuxlab>