Skip to content

AI junk - #3719

Closed
hoangvu14092005 wants to merge 1 commit into
pallets:mainfrom
hoangvu14092005:improve/quality/sentinel-repr-format-has-no-visible-test
Closed

AI junk#3719
hoangvu14092005 wants to merge 1 commit into
pallets:mainfrom
hoangvu14092005:improve/quality/sentinel-repr-format-has-no-visible-test

Conversation

@hoangvu14092005

Copy link
Copy Markdown

Code Quality

Problem

The Sentinel enum's repr method returns f"{self.class.name}.{self.name}", producing strings like "Sentinel.UNSET" and "Sentinel.FLAG_NEEDS_VALUE". This format is part of Click's public debug/error output contract — the docstring on FLAG_NEEDS_VALUE explicitly references it appearing in Option.consume_value flow. A change to this repr format would silently break user debug output and log parsing but go unnoticed without a test.

Severity: medium
File: src/click/_utils.py

Solution

Add tests in tests/test_utils.py asserting repr(Sentinel.UNSET) == "Sentinel.UNSET" and repr(Sentinel.FLAG_NEEDS_VALUE) == "Sentinel.FLAG_NEEDS_VALUE". Also assert str(sentinel) == repr(sentinel) since they share the default Enum behavior, and verify the format is stable across instances (e.g., repr(Sentinel.UNSET) is identical on each call).

Changes

  • tests/test_utils.py (modified)

Contributed by Lê Thành Chỉnh
Code is a tool. Mindset is the real value.

Closes #3718

The Sentinel enum's __repr__ method returns f"{self.__class__.__name__}.{self.name}", producing strings like "Sentinel.UNSET" and "Sentinel.FLAG_NEEDS_VALUE". This format is part of Click's public debug/error output contract — the docstring on FLAG_NEEDS_VALUE explicitly references it appearing in Option.consume_value flow. A change to this repr format would silently break user debug output and log parsing but go unnoticed without a test.

Affected files: test_utils.py

Signed-off-by: Hoàng Anh Vũ <202087943+hoangvu14092005@users.noreply.github.com>
@hoangvu14092005

Copy link
Copy Markdown
Author

Auto-closed: CI checks failed

The following checks failed: PyPy, 3.10, main, Windows, 3.14, Mac, 3.13, 3.11, 3.14t, 3.12

Closing this PR since required CI checks did not pass. Sorry for the inconvenience.

@davidism davidism changed the title refactor(click): sentinel.__repr__ format has no visible test coverage AI junk Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI junk

1 participant