Open the context
Choose the project folder and name the files or behavior involved.
Decode a color written as a hash followed by exactly six ASCII hexadecimal digits into three channel integers. Check mixed case and both channel extremes, rejecting shorthand, surrounding whitespace and Unicode lookalike digits.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def rgb_hex(text):
digits = "0123456789abcdefABCDEF"
if not isinstance(text, str) or len(text) != 7 or text[0] != "#":
raise ValueError("color.format")
if any(char not in digits for char in text[1:]):
raise ValueError("color.digit")
return tuple(int(text[i:i + 2], 16) for i in (1, 3, 5))The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.