Skip to content

docs: add docstrings to the grep pattern helpers - #1400

Open
HendyGH wants to merge 3 commits into
wireservice:masterfrom
HendyGH:docs-grep-pattern-helpers-20261123
Open

HendyGH wants to merge 3 commits into
wireservice:masterfrom
HendyGH:docs-grep-pattern-helpers-20261123

Conversation

@HendyGH

@HendyGH HendyGH commented Nov 25, 2026

Copy link
Copy Markdown

The pattern helpers in csvkit/grep.py had no docstrings, even though they are the core of FilteringCSVReader's filtering — pattern_as_function converts every pattern (string, regex or callable) into the test function the reader applies to each row, and regex_callable wraps a compiled regular expression for that purpose — so anyone reading the module (or help()) got no description of how a pattern becomes a test.

This PR adds a docstring to pattern_as_function (what each pattern type becomes) and to the regex_callable class (what calling the wrapper returns, and that FilteringCSVReader treats the result as pass or fail). No behaviour is changed.

No >>> examples are included.

Two new tests in TestGrep (tests/test_grep.py) cover the documented behaviour: a callable is returned unchanged, a compiled regex is wrapped in a regex_callable, a string becomes a substring test, and calling a regex_callable returns a match object or None.

Scope: one scoped change — two docstrings + tests for those helpers only. It does not close any issue (no open issue asks for these docstrings).

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