Skip to content

Raise TypeError when WATCHMAN_CHECKS is a string instead of a sequence#231

Merged
mwarkentin merged 1 commit intomainfrom
michaelwarkentin/fix/watchman-checks-string-validation
Mar 8, 2026
Merged

Raise TypeError when WATCHMAN_CHECKS is a string instead of a sequence#231
mwarkentin merged 1 commit intomainfrom
michaelwarkentin/fix/watchman-checks-string-validation

Conversation

@mwarkentin
Copy link
Owner

Summary

  • Fixes Round Brackets don't work when using single check #149. When WATCHMAN_CHECKS is defined with parentheses but without a trailing comma (e.g. WATCHMAN_CHECKS = ('single.check')), Python treats it as a plain string rather than a tuple. frozenset() then iterates over individual characters, producing a confusing ImportError like "h doesn't look like a module path".
  • Adds an early isinstance(WATCHMAN_CHECKS, str) check in get_checks() that raises a clear TypeError with guidance on how to fix the setting.
  • Adds a test that verifies the TypeError is raised when WATCHMAN_CHECKS is accidentally a string.

Test plan

  • New test test_get_checks_raises_type_error_when_checks_is_a_string passes
  • Full test suite passes with no regressions (64 passed, 1 skipped)

Made with Cursor

Fixes #149. When WATCHMAN_CHECKS is set with parentheses but without a
trailing comma (e.g. `('single.check')`), Python treats it as a plain
string. Calling `frozenset()` on a string iterates over characters,
leading to a confusing ImportError. This adds an early isinstance check
with a clear error message guiding the user to use a list or trailing
comma.

Made-with: Cursor
@mwarkentin mwarkentin merged commit cc46456 into main Mar 8, 2026
20 checks passed
@mwarkentin mwarkentin deleted the michaelwarkentin/fix/watchman-checks-string-validation branch March 8, 2026 03:06
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.

Round Brackets don't work when using single check

1 participant