Skip to content

Add XBRL filter for filer-defined tags - #1992

Merged
dgunning merged 4 commits into
dgunning:mainfrom
joshhheo:filer-defined-xbrl-tags
Nov 28, 2026
Merged

dgunning merged 4 commits into
dgunning:mainfrom
joshhheo:filer-defined-xbrl-tags

Conversation

@joshhheo

Copy link
Copy Markdown
Contributor

What this changes

Adds by_extension() to filing XBRL queries so users can retrieve facts tagged with concepts defined by the filer. The filter compares each fact’s namespace URI against the namespaces declared by the filing’s schemas. For example, filing.xbrl().query().by_extension().to_dataframe() returns the matching facts as a DataFrame.

Fixes #1991

Verification

  • Ground truth. Tesla’s Form 10-Q for the quarter ended June 30, 2024, accession 0001628280-24-032662, reports digital assets, net of $184 million. The test checks that the filter returns that filer-defined fact and excludes us-gaap:Assets.
  • Changelog. Added changelog.d/filer-defined-xbrl-tags.added.md.

All 19 targeted XBRL tests passed, and the changelog check passed.

AI assistance

  • Assisted. OpenAI Codex (GPT-6).

@dgunning dgunning added the guard-scan Maintainer-applied: runs the Agent config guard on this PR label Nov 19, 2026
@joshhheo joshhheo closed this Nov 19, 2026
@joshhheo joshhheo reopened this Nov 23, 2026

@dgunning dgunning left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The filter does what it should on a filing whose schema is loaded: on Apple's FY2023 fixture it returns exactly the 77 aapl: facts, and the fast XBRL tests pass on the branch. There are two behaviours I'd like fixed before merging.

Stitched queries crash. XBRLS([...]).query().by_extension() raises AttributeError: 'StitchedFactsView' object has no attribute 'xbrl', because the method reads self._facts_view.xbrl, which only a single filing's query has. Either make it work across the stitched filings (each one's target namespaces) or raise a clear error saying it isn't supported on stitched queries.

A missing schema returns nothing, silently. XBRL.from_files(instance_file=...) without a schema gives 0 rows, and so does the Tesla fixture from your test when it's loaded with XBRL.from_directory() (0 of 1,059 facts), because that loader doesn't pick up the .xsd.xml file name. A user can't tell "this filer has no extension facts" apart from "the schema never loaded". When no target namespace is known, please raise an error that says the filing's schema wasn't loaded, rather than returning an empty result.

Two smaller things:

  • Could you name the changelog fragment 1991.added.md and give it a measured value and the issue reference? For example, Tesla's June 2024 10-Q (0001628280-24-032662) returning its $184 million digital-assets fact, then (GH #1991).
  • by_extension() isn't mentioned in the docs yet. A short entry next to the other query filters in docs/api/xbrl.md would let people find it.

If the first two are in soon, this can still make 6.4.0.

@joshhheo
joshhheo requested a review from dgunning November 24, 2026 16:20

@dgunning dgunning left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this covers everything from my last review. Stitched queries now raise a clear NotImplementedError, and a missing schema raises ValidationError instead of returning nothing. That includes the Tesla fixture loaded with XBRL.from_directory(), which used to give 0 of 1,059 facts.

I ran it against a few filings outside the tests, and each returned only the filer's own prefix: JPMorgan's FY2024 10-K (1,631 of 7,778 facts, jpm), SAP's 20-F (1,169 of 4,102, sap) and NextEra's September 2025 10-Q (566 of 2,125, nee). Tesla's June 2024 10-Q gives 129 extension facts, with f-50 as tsla:DigitalAssetsNetNonCurrent at $184 million. The regression tests and the fast XBRL suite pass, and the branch merges cleanly with main.

from_directory() not picking up the .xsd.xml schema file is older than this PR, so I'll track it separately rather than hold this up. I'll merge it for 6.5.

@dgunning
dgunning merged commit a1aaa1d into dgunning:main Nov 28, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

guard-scan Maintainer-applied: runs the Agent config guard on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a filter for filer-defined XBRL tags

2 participants