Parse dimensions from xbrli:scenario as well as xbrli:segment - #179
Open
DMZ22 wants to merge 1 commit into
Open
Conversation
XBRL 2.1 lets a context carry dimensional information in either xbrli:segment, a child of xbrli:entity, or xbrli:scenario, a direct child of the context. Only segment was read, so every ESEF filing came back with len(fact.context.segments) == 0 while US SEC filings parsed fine. The explicitMember/typedMember block is extracted into _parse_dimensions and run for both containers, so the two are handled identically.
manusimidt
self-requested a review
July 26, 2026 07:47
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.
Closes #159.
_parse_context_elementsreads dimensional information only fromxbrli:entity/xbrli:segment. Across the whole ofinstance.pybefore this change:segmentappears 14 times,explicitMember3,typedMember3, andscenariozero times.XBRL 2.1 allows a context to carry dimensions in either container —
xbrli:segment, which is a child ofxbrli:entity, orxbrli:scenario, which is a direct child of the context. US SEC filings generally use segment, which is why they parse correctly, while ESEF and other IFRS filings use scenario. That is why the reporter sawlen(fact.context.segments) == 0for roughly 20 European filers while US filings were fine.The two are meant to behave identically, so rather than duplicating the ~50-line explicitMember/typedMember block I extracted it into
_parse_dimensions(container, context, ns_map, taxonomy, taxParser)and call it for both paths:The extracted body is unchanged apart from
segment.findallbecomingcontainer.findall, so segment-based filings keep behaving exactly as before. Members from both containers land incontext.segments, which keeps the existing public attribute andFact.to_dict()'sdimensionsmapping working untouched.Tests.
tests/test_context_dimensions.pyis new and runs fully offline — the existing instance fixtures import a remote FASB schema, so instead of adding another network-dependent fixture I drive_parse_context_elementsdirectly with a stub taxonomy. It covers an explicit member in segment, an explicit member in scenario, a typed member in scenario, a context carrying both containers at once, and a context with no dimensions.Reverting
instance.pywhile keeping the tests fails exactly the three scenario cases; the segment and no-dimension cases pass either way, deliberately, so they catch any regression to the existing path. The offline suite (test_context_dimensions,test_transformation,test_uri_helper) is 8 passed.One thing I could not do locally: the network-backed tests in
test_local_instance.pyfetchxbrl.fasb.org, so I have not run those here — they exercise a code path this change does not alter, but worth a look in CI.