AI junk - #3719
Closed
hoangvu14092005 wants to merge 1 commit into
Closed
Conversation
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>
Author
Auto-closed: CI checks failedThe 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
mediumFile:
src/click/_utils.pySolution
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