Skip to content

Fix typo and NO_COLOR environment variable handling#30

Open
assisted-by-ai wants to merge 1 commit intoKicksecure:masterfrom
assisted-by-ai:claude/debug-unicode-show-Gn083
Open

Fix typo and NO_COLOR environment variable handling#30
assisted-by-ai wants to merge 1 commit intoKicksecure:masterfrom
assisted-by-ai:claude/debug-unicode-show-Gn083

Conversation

@assisted-by-ai
Copy link
Copy Markdown

This PR fixes two issues in the unicode_show codebase:

Summary of Changes:

  • Corrected a typo in the test string where "ghjiklmnopqrstuvwxyz" was missing the 'i' character
  • Fixed the NO_COLOR environment variable check to properly detect when the variable is unset
  • Corrected a test assertion that was checking for the wrong expected output

Key Changes:

  • Fixed typo in test_clean_ascii(): Changed "abcdefghjiklmnopqrstuvwxyz" to "abcdefghijklmnopqrstuvwxyz" to include the missing 'i'
  • Updated NO_COLOR environment variable logic in main(): Changed from os.getenv("NO_COLOR") != "1" to os.getenv("NO_COLOR") is None to properly follow the NO_COLOR specification, which disables color output when the variable is set to any value (not just "1")
  • Fixed test expectation in test_pty_color(): Changed stdout_string=expect_string_color to stdout_string=expect_string_nocolor to match the correct expected behavior

Implementation Details:
The NO_COLOR specification states that color output should be disabled whenever the NO_COLOR environment variable is present, regardless of its value. The previous implementation only checked if it was set to "1", which was incorrect. The fix uses is None to check if the variable is unset, which is the proper way to detect the absence of an environment variable in Python.

https://claude.ai/code/session_014Qvwfhuw1DH4BJNdzrM6x1

- NO_COLOR check now disables color when the variable is present
  regardless of value, per the no-color.org spec. Previously only
  NO_COLOR=1 was honored.
- Fix transposed "ji" → "ij" in test_clean_ascii alphabet string.
- Update test_pty_color to expect no-color output when NO_COLOR=0,
  matching the corrected behavior.

https://claude.ai/code/session_014Qvwfhuw1DH4BJNdzrM6x1
Copy link
Copy Markdown
Contributor

@ArrayBolt3 ArrayBolt3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly redundant, but I accepted the typo fix in ArrayBolt3@d0e253b.

test_string: str = (
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]"
+ "^_`abcdefghjiklmnopqrstuvwxyz{|}~\n"
+ "^_`abcdefghijklmnopqrstuvwxyz{|}~\n"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted.

main_func=unicode_show_main,
argv0=self.argv0,
stdout_string=expect_string_color,
stdout_string=expect_string_nocolor,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was removed in an earlier commit.

USE_COLOR = (
not os.getenv("NOCOLOR")
and os.getenv("NO_COLOR") != "1"
and os.getenv("NO_COLOR") is None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed in a different PR (and this is the wrong way to fix it).

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.

3 participants