edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

Statement unit display infers EPS units from the opaque reference ID

Open synfonia-llc opened this issue 1 month ago • 1 comments

Issue Type

  • [ ] Data Quality Issue (incorrect financial values, missing data)
  • [x] XBRL Parsing Issue (statement rendering, concept mapping)
  • [ ] Filing Access Issue (download failures, attachment problems)
  • [ ] Performance Issue (slow operations, memory problems)
  • [ ] Compatibility Issue (platform/dependency conflicts)
  • [ ] Documentation Issue (unclear instructions, missing examples)

Environment

EdgarTools Version: main@2323d732 and v5.62.0@5068cc54 (both report 5.62.0)
Python Version: 3.14.4
Operating System: Windows 11

Bug Description

What you expected to happen: Display the parsed divided unit as USD per share and the monetary unit as USD, using their definitions.

What actually happened: The divided USD/shares definition is available, but get_unit_display_name returns shares; the simple USD definition displays as u_usd.

main@2323d732:

U_UnitedStatesOfAmericaDollarsShare definition: {'type': 'divide', 'numerator': ['iso4217:USD'], 'denominator': ['xbrli:shares']} display: shares
U_USD definition: {'type': 'simple', 'measure': 'iso4217:USD'} display: u_usd

v5.62.0@5068cc54:

U_UnitedStatesOfAmericaDollarsShare definition: {'type': 'divide', 'numerator': ['iso4217:USD'], 'denominator': ['xbrli:shares']} display: shares
U_USD definition: {'type': 'simple', 'measure': 'iso4217:USD'} display: u_usd

The same labels reach Statement.to_dataframe(include_unit=True). On the repository's Microsoft fixture (tests/fixtures/xbrl/msft/10k_2024), the income statement's basic EPS row, whose unit U_UnitedStatesOfAmericaDollarsShare is parsed as iso4217:USD divided by shares, has the same unit label as the weighted-average share count, on both builds:

                                                        concept    unit
0   us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax   u_usd
37                                us-gaap_EarningsPerShareBasic  shares
40        us-gaap_WeightedAverageNumberOfSharesOutstandingBasic  shares

Error message (if any): No exception is raised in the reproduction.

Reproduction

Company/Ticker: Not applicable; explicitly synthetic parser input Time Period: Not applicable to a company's financial results Relevant Forms: Inline/XBRL parser example; no filing acquisition required

Minimal code to reproduce:

from edgar import set_identity
set_identity("Your Name [email protected]")
from edgar.xbrl import XBRL
from edgar.xbrl.core import get_unit_display_name

xml = '''<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
<xbrli:unit id="U_UnitedStatesOfAmericaDollarsShare"><xbrli:divide><xbrli:unitNumerator><xbrli:measure>iso4217:USD</xbrli:measure></xbrli:unitNumerator><xbrli:unitDenominator><xbrli:measure>xbrli:shares</xbrli:measure></xbrli:unitDenominator></xbrli:divide></xbrli:unit>
<xbrli:unit id="U_USD"><xbrli:measure>iso4217:USD</xbrli:measure></xbrli:unit>
</xbrli:xbrl>'''
x = XBRL()
x.parser.parse_instance_content(xml)
for unit_id, definition in x.units.items():
    print(unit_id, "definition:", definition, "display:", get_unit_display_name(unit_id))

The statement-level output above comes from this, run from the repository root:

from edgar.xbrl import XBRL
m = XBRL.from_directory('tests/fixtures/xbrl/msft/10k_2024')
df = m.statements.income_statement().to_dataframe(include_unit=True)
concepts = ['us-gaap_EarningsPerShareBasic',
            'us-gaap_RevenueFromContractWithCustomerExcludingAssessedTax',
            'us-gaap_WeightedAverageNumberOfSharesOutstandingBasic']
print(df[df.concept.isin(concepts)][['concept', 'unit']].drop_duplicates().to_string())

Additional Context

Source and intent: implementation and API/guide. The function matches substrings of the lower-cased unit ID; the parsed measures are already in xbrl.units.

XBRL 2.1 sections 4.8.1–4.8.4 separate the reference identifier from the unit definition.

Related: #850 and #1170. #850 added a currency field on facts. #1170 fixed divided-unit parsing. This example has a correctly parsed divided unit and a wrong statement display name.

The synthetic reproduction uses literal native-parser inputs and runs offline; it does not establish a company amount, incidence rate, or comprehensive conformance result.


This issue will be handled using EdgarTools' systematic issue resolution workflow. A reproduction test will be created to verify the fix.

synfonia-llc avatar Oct 22 '26 15:10 synfonia-llc

@dgunning, here is our current thinking on the root cause, proposed behavior, and coordination with other issues.

Root Cause:

get_unit_display_name infers measurement from the opaque unit reference ID. A correctly parsed USD-per-share value can therefore be labeled as shares.

Proposed Behavior:

Resolve both statement DataFrame paths' unit labels from each selected cell's complete unit definition, using #1747's shared descriptor/classifier. Keep per-share, shares, money and complete compound expressions distinct, and show mixed or unavailable row units explicitly. Bind labels to the selected source occurrence without changing its amount, period, accuracy or presentation sign. Retain the one-argument helper as a documented legacy heuristic while authoritative statement consumers always supply a definition or explicit unavailable state.

Coordination:

I recommend a separate PR after agreeing the common contract with #1747, followed by #1737's formatting work, resolving #1793's unit-design hold. Coordinate #1655's source-cell binding independently and keep unit labels separate from the exact scale/sign, retained-input and raw-precision PR.

Below, please find the full design document. Please let me know your thoughts.

Brian

Attachment: design-public.md, Resolve statement unit labels from their definitions — proposal for #1746.

AI assistance: Codex; GPT-6.1 Sol (High) performed current-main scouting, source verification and final writing; GPT-6 Astra (Max) developed the architecture and completed an independent financial-statement review. Implementation checks remain proposed.

synfonia-llc avatar Oct 27 '26 11:10 synfonia-llc