From a92d4ffdd7bc6b9377f1b0c58330a92310214ffd Mon Sep 17 00:00:00 2001 From: Dror Shvadron Date: Fri, 21 Nov 2025 20:55:51 -0500 Subject: [PATCH] Fix TypeError with Click Sentinel in Python 3.14 Add explicit default=None to click.Option definitions for -m and -k flags to prevent Click 8.3.1 from using Sentinel.UNSET as default value. When Click options don't have an explicit default, Click 8.3.1 uses Sentinel.UNSET (an enum). This causes a TypeError when the code tries to call len() on the sentinel value in mark/expression.py:92. The fix ensures both marker_expression and expression options default to None, which the existing 'if not keywordexpr:' checks handle correctly. Fixes compatibility with Python 3.14 and Click 8.3.1. Tested with the minimal reproduction case - pytask now runs successfully. --- src/_pytask/mark/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/_pytask/mark/__init__.py b/src/_pytask/mark/__init__.py index 9d49b6e0..fd4a2f8c 100644 --- a/src/_pytask/mark/__init__.py +++ b/src/_pytask/mark/__init__.py @@ -92,12 +92,14 @@ def pytask_extend_command_line_interface(cli: click.Group) -> None: metavar="MARKER_EXPRESSION", type=str, help="Select tasks via marker expressions.", + default=None, ), click.Option( ["-k", "expression"], metavar="EXPRESSION", type=str, help="Select tasks via expressions on task ids.", + default=None, ), ] for command in ("build", "clean", "collect"):