-
-
Notifications
You must be signed in to change notification settings - Fork 386
fix: support search/grep on plain-text filings (#819) #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dgunning
merged 1 commit into
dgunning:main
from
0ywfe:fix/issue-819-search-grep-on-text-filings
May 25, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
60 changes: 60 additions & 0 deletions
60
tests/issues/regression/test_issue_819_search_grep_on_text_filings.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| """Regression test for #819 — search()/grep() failed on plain-text filings.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from edgar import Company | ||
|
|
||
|
|
||
| PCG_TEXT_10K_ACCESSION = "0000929624-00-000321" | ||
|
|
||
|
|
||
| def _pcg_oldest_10k(): | ||
| filings = Company("PCG").get_filings(form="10-K") | ||
| target = next( | ||
| (f for f in filings if f.accession_no == PCG_TEXT_10K_ACCESSION), | ||
| None, | ||
| ) | ||
| assert target is not None, f"PCG 10-K {PCG_TEXT_10K_ACCESSION} missing from EDGAR results" | ||
| return target | ||
|
|
||
|
|
||
| @pytest.mark.network | ||
| def test_text_filing_html_is_none_but_text_is_populated(): | ||
| filing = _pcg_oldest_10k() | ||
| assert filing.html() is None | ||
| text = filing.text() | ||
| assert text is not None | ||
| assert len(text) > 100_000 | ||
| assert "employees" in text.lower() | ||
|
|
||
|
|
||
| @pytest.mark.network | ||
| def test_sections_falls_back_to_text_for_plain_text_filings(): | ||
| filing = _pcg_oldest_10k() | ||
| sections = filing.sections() | ||
| assert isinstance(sections, list) | ||
| assert len(sections) > 1 | ||
| assert any("employees" in s.lower() for s in sections) | ||
|
|
||
|
|
||
| @pytest.mark.network | ||
| def test_search_works_on_plain_text_filing(): | ||
| filing = _pcg_oldest_10k() | ||
| results = filing.search("employees") | ||
| assert results is not None | ||
| assert len(results) >= 1 | ||
|
|
||
|
|
||
| @pytest.mark.network | ||
| def test_grep_works_on_plain_text_filing(): | ||
| filing = _pcg_oldest_10k() | ||
| matches = filing.grep("employees") | ||
| assert len(matches) >= 1 | ||
|
|
||
|
|
||
| @pytest.mark.network | ||
| def test_search_grep_still_work_on_html_filings(): | ||
| newest = Company("PCG").get_filings(form="10-K")[0] | ||
| assert newest.html() is not None | ||
| assert len(newest.search("employees")) > 0 | ||
| assert len(newest.grep("employees")) > 0 | ||
66 changes: 0 additions & 66 deletions
66
tests/issues/regression/test_issue_819_text_filing_search.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I do in tests
filing = Filing(form='10-K', filing_date='2000-03-08', company='PG&E CORP', cik=1004980, accession_no='0000929624-00-000321')
'''
How to find a filing by accession number