Skip to content

Nicer matcher reprs#122

Merged
kaste merged 4 commits intomasterfrom
nicer-matcher-reprs
Mar 11, 2026
Merged

Nicer matcher reprs#122
kaste merged 4 commits intomasterfrom
nicer-matcher-reprs

Conversation

@kaste
Copy link
Owner

@kaste kaste commented Mar 11, 2026

No description provided.

kaste added 4 commits March 11, 2026 18:47
Use repr-style formatting for value-like matchers so string values are quoted
consistently in diagnostics and nested matcher output.

Also make Matches report only explicitly requested regex flags and render
patterns via repr. Add matcher_repr_test.py with coverage for the updated
repr behavior.
Make ArgThat repr informative by labeling predicate kind and optional source
line, e.g. "def is_positive at line N", "lambda at line N", and callable
instance labels. This improves diagnostics without requiring custom ArgThat
subclasses.

Add defensive introspection fallbacks so odd/broken callables do not break
repr generation. Handle functools.partial explicitly, and add regression tests
covering builtins, numpy ufuncs, partial numpy functions, and broken
__name__ introspection.
Improve Any repr readability for type constraints while preserving
robustness for unusual objects. Type constraints now render as concise
names (e.g. "<Any: int>", "<Any: (int, str)>") and still fall back
safely for non-type values.
Use safe repr handling in ValueMatcher and Contains so diagnostic
rendering cannot fail when user objects implement a broken __repr__.

Also preserve explicit flags in Matches.__repr__ when a compiled pattern
is passed, while still omitting default regex engine flags.
@kaste kaste force-pushed the nicer-matcher-reprs branch from d005566 to 23a4740 Compare March 11, 2026 19:52
@kaste kaste merged commit aece8f9 into master Mar 11, 2026
50 checks passed
@kaste kaste deleted the nicer-matcher-reprs branch March 11, 2026 19:58
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.

1 participant