Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pattern helpers in
csvkit/grep.pyhad no docstrings, even though they are the core ofFilteringCSVReader's filtering —pattern_as_functionconverts every pattern (string, regex or callable) into the test function the reader applies to each row, andregex_callablewraps a compiled regular expression for that purpose — so anyone reading the module (orhelp()) 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 theregex_callableclass (what calling the wrapper returns, and thatFilteringCSVReadertreats 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 aregex_callable, a string becomes a substring test, and calling aregex_callablereturns 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).