xbrlkit 0.7.0__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/PKG-INFO +3 -3
  2. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/README.md +2 -2
  3. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/pyproject.toml +1 -1
  4. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_deserialize.py +40 -0
  5. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/deserialize/holon.py +18 -3
  6. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/deserialize/tavi.py +10 -5
  7. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/.gitignore +0 -0
  8. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/LICENSE +0 -0
  9. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/pytest.ini +0 -0
  10. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/ruff.toml +0 -0
  11. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/__init__.py +0 -0
  12. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/conftest.py +0 -0
  13. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_arelle_cache.py +0 -0
  14. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_config.py +0 -0
  15. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_documents.py +0 -0
  16. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_edgar.py +0 -0
  17. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_efts.py +0 -0
  18. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_lpg.py +0 -0
  19. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_oim.py +0 -0
  20. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_parity.py +0 -0
  21. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_parse.py +0 -0
  22. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_query.py +0 -0
  23. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_serialize.py +0 -0
  24. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_serve.py +0 -0
  25. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_tavi.py +0 -0
  26. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_text_ixbrl.py +0 -0
  27. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_text_narrative.py +0 -0
  28. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_text_parts.py +0 -0
  29. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/tests/test_text_tables.py +0 -0
  30. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/__init__.py +0 -0
  31. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/__init__.py +0 -0
  32. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/__init__.py +0 -0
  33. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/README.md +0 -0
  34. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/extractTestcase.sh +0 -0
  35. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/extractTestcase.xsl +0 -0
  36. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/runIxtSecTests.sh +0 -0
  37. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/saxon9.jar +0 -0
  38. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/testcase.xml +0 -0
  39. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/tests.xml +0 -0
  40. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/conf/tests.xsd +0 -0
  41. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/text2num.py +0 -0
  42. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-boolballotbox.xml +0 -0
  43. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-countrynameen.xml +0 -0
  44. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-datequarterend.xml +0 -0
  45. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-durday.xml +0 -0
  46. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-durhour.xml +0 -0
  47. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-durmonth.xml +0 -0
  48. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-durweek.xml +0 -0
  49. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-durwordsen.xml +0 -0
  50. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-duryear.xml +0 -0
  51. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-edgarprovcountryen.xml +0 -0
  52. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-entityfilercategoryen.xml +0 -0
  53. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-exchnameen.xml +0 -0
  54. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-numwordsen.xml +0 -0
  55. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-stateprovnameen.xml +0 -0
  56. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/ixt-sec-yesnoballotbox.xml +0 -0
  57. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/registry/transform-registry.xml +0 -0
  58. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/arelle_plugins/EDGAR/transform/transformationRegistry/schema/inlinexbrl-sec-transformation.xsd +0 -0
  59. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/ontology/v1/context.jsonld +0 -0
  60. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/_vendor/ontology/v1/shapes.ttl +0 -0
  61. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/cli.py +0 -0
  62. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/config.py +0 -0
  63. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/deserialize/README.md +0 -0
  64. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/deserialize/__init__.py +0 -0
  65. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/README.md +0 -0
  66. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/__init__.py +0 -0
  67. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/client.py +0 -0
  68. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/download.py +0 -0
  69. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/efts.py +0 -0
  70. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/filing_index.py +0 -0
  71. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/rate_limit.py +0 -0
  72. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/edgar/submission.py +0 -0
  73. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/filings_org/README.md +0 -0
  74. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/filings_org/__init__.py +0 -0
  75. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/filings_org/client.py +0 -0
  76. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/filings_org/download.py +0 -0
  77. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/model.py +0 -0
  78. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/namespaces.py +0 -0
  79. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/parse/README.md +0 -0
  80. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/parse/__init__.py +0 -0
  81. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/parse/arelle_load.py +0 -0
  82. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/parse/cache.py +0 -0
  83. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/parse/ids.py +0 -0
  84. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/parse/to_model.py +0 -0
  85. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/periods.py +0 -0
  86. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/py.typed +0 -0
  87. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/query.py +0 -0
  88. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/schema/__init__.py +0 -0
  89. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/README.md +0 -0
  90. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/__init__.py +0 -0
  91. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/_kernel/__init__.py +0 -0
  92. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/_kernel/bundle.py +0 -0
  93. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/_kernel/context.py +0 -0
  94. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/_kernel/holon.py +0 -0
  95. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/_kernel/jsonld.py +0 -0
  96. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/_values.py +0 -0
  97. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/classify.py +0 -0
  98. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/graph.py +0 -0
  99. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/holon.py +0 -0
  100. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/lpg.py +0 -0
  101. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/oim.py +0 -0
  102. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serialize/tavi.py +0 -0
  103. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serve/README.md +0 -0
  104. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serve/__init__.py +0 -0
  105. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serve/server.py +0 -0
  106. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serve/session.py +0 -0
  107. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/serve/tools.py +0 -0
  108. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/text/README.md +0 -0
  109. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/text/__init__.py +0 -0
  110. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/text/ixbrl.py +0 -0
  111. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/text/narrative.py +0 -0
  112. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/text/parts.py +0 -0
  113. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/text/tables.py +0 -0
  114. {xbrlkit-0.7.0 → xbrlkit-0.7.2}/xbrlkit/text/xml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: xbrlkit
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: Work with XBRL filings above Arelle: one parse, portable models
5
5
  Project-URL: Repository, https://github.com/RoboFinSystems/xbrlkit
6
6
  Project-URL: Homepage, https://github.com/RoboFinSystems/xbrlkit#readme
@@ -206,8 +206,8 @@ behind its document search is built from `xbrlkit.text`.
206
206
  [Filing Ladder](https://github.com/HarbingerFinLab/filing-ladder) benchmark —
207
207
  one filing handed to the same language model in every representation — built
208
208
  its 26-filing corpus of 2024–2025 10-Ks and 10-Qs with this package. Each
209
- projection is a rung of the ladder, so the
210
- [v0.1 results](https://github.com/HarbingerFinLab/filing-ladder/blob/main/results/v0.1-sonnet-5/README.md)
209
+ projection is a rung of the ladder, so its
210
+ [published results](https://github.com/HarbingerFinLab/filing-ladder/blob/main/results/README.md)
211
211
  are also a measurement of what a model can do with each of these outputs. That
212
212
  corpus is this package's test bench too: the text sections were checked against
213
213
  the filing's own text-block facts on all 26 filings, the property graph row for
@@ -150,8 +150,8 @@ behind its document search is built from `xbrlkit.text`.
150
150
  [Filing Ladder](https://github.com/HarbingerFinLab/filing-ladder) benchmark —
151
151
  one filing handed to the same language model in every representation — built
152
152
  its 26-filing corpus of 2024–2025 10-Ks and 10-Qs with this package. Each
153
- projection is a rung of the ladder, so the
154
- [v0.1 results](https://github.com/HarbingerFinLab/filing-ladder/blob/main/results/v0.1-sonnet-5/README.md)
153
+ projection is a rung of the ladder, so its
154
+ [published results](https://github.com/HarbingerFinLab/filing-ladder/blob/main/results/README.md)
155
155
  are also a measurement of what a model can do with each of these outputs. That
156
156
  corpus is this package's test bench too: the text sections were checked against
157
157
  the filing's own text-block facts on all 26 filings, the property graph row for
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xbrlkit"
3
- version = "0.7.0"
3
+ version = "0.7.2"
4
4
  description = "Work with XBRL filings above Arelle: one parse, portable models"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -43,7 +43,10 @@ from xbrlkit.model import (
43
43
  )
44
44
  from xbrlkit.parse.ids import unit_id
45
45
  from xbrlkit.periods import duration_period, instant_period, period_from_interval
46
+ from xbrlkit.deserialize.holon import _scheme_for
47
+ from xbrlkit.namespaces import ENTITY_SCHEME
46
48
  from xbrlkit.serialize import to_holon, to_tavi
49
+ from xbrlkit.serialize._values import CIK_SCHEME
47
50
  from xbrlkit.serve import tools
48
51
  from xbrlkit.serve.session import FilingSession, SourceError
49
52
 
@@ -590,6 +593,43 @@ def test_a_holon_tells_a_nil_fact_from_an_empty_one(model: XbrlModel) -> None:
590
593
  assert nil[0].value_str is None
591
594
 
592
595
 
596
+ def test_a_report_that_is_not_an_sec_filing_keeps_its_identity(
597
+ model: XbrlModel,
598
+ ) -> None:
599
+ """A ledger's own report identifies its entity under its own scheme.
600
+
601
+ Both importers used to lose half of that: Tavi looked for the entity's label
602
+ under a `cik:` name it had reconstructed rather than the SQName the document
603
+ wrote, and the holon called any entity an SEC CIK because that is the model's
604
+ default. Found on a real RoboLedger report, whose two files disagreed about
605
+ the same company.
606
+ """
607
+ model.entity = EntityIdentity(
608
+ cik="entity_kg19ed34f81c37ba3f31fa",
609
+ scheme=ENTITY_SCHEME,
610
+ name="Harbinger Consultants LLC",
611
+ )
612
+ for got in (from_tavi_json(to_tavi(model)), from_holon_json(to_holon(model))):
613
+ assert got.entity.name == "Harbinger Consultants LLC"
614
+ assert got.entity.cik == "entity_kg19ed34f81c37ba3f31fa"
615
+ assert got.entity.scheme == ENTITY_SCHEME
616
+
617
+
618
+ def test_a_holon_with_no_scheme_does_not_invent_an_sec_one(model: XbrlModel) -> None:
619
+ """A holon written from a `StatementBundle` carries no scheme at all — the
620
+ bundle has no field for one — so the identifier has to answer for it."""
621
+ model.entity = EntityIdentity(cik="entity_kg1", scheme=ENTITY_SCHEME, name="Acme")
622
+ document = json.loads(to_holon(model))
623
+ for graph in document["@graph"]:
624
+ for node in graph["@graph"]:
625
+ if "Entity" in str(node.get("@type")):
626
+ node.pop("scheme", None)
627
+ got = from_holon_json(json.dumps(document))
628
+ assert got.entity.scheme == ENTITY_SCHEME
629
+ # A ten-digit identifier still reads as what it is.
630
+ assert _scheme_for("0001234567") == CIK_SCHEME
631
+
632
+
593
633
  # -- the two agree ---------------------------------------------------------------
594
634
 
595
635
 
@@ -55,7 +55,8 @@ from ..model import (
55
55
  XbrlFact,
56
56
  XbrlModel,
57
57
  )
58
- from ..namespaces import CONCEPT_BASE, HOLON_VOCAB
58
+ from ..namespaces import CONCEPT_BASE, ENTITY_SCHEME, HOLON_VOCAB
59
+ from ..serialize._values import CIK_SCHEME
59
60
  from ..serialize.tavi import LABEL_ROLE_TYPES
60
61
  from ..parse.ids import unit_id
61
62
  from ..periods import duration_period, forever_period, instant_period
@@ -306,9 +307,10 @@ def _reference(value: Any) -> str:
306
307
 
307
308
  def _entity(nodes: Sequence[Mapping[str, Any]]) -> EntityIdentity:
308
309
  node = _mapping(nodes[0]) if nodes else {}
310
+ identifier = _text(node.get("internalId")) or ""
309
311
  return EntityIdentity(
310
- cik=_text(node.get("internalId")) or "",
311
- scheme=_text(node.get("scheme")) or "http://www.sec.gov/CIK",
312
+ cik=identifier,
313
+ scheme=_text(node.get("scheme")) or _scheme_for(identifier),
312
314
  name=_text(node.get("prefLabel")),
313
315
  legal_name=_text(node.get("legalName")),
314
316
  ein=_text(node.get("ein")),
@@ -317,6 +319,19 @@ def _entity(nodes: Sequence[Mapping[str, Any]]) -> EntityIdentity:
317
319
  )
318
320
 
319
321
 
322
+ def _scheme_for(identifier: str) -> str:
323
+ """The scheme an entity is identified under when the holon does not say.
324
+
325
+ A holon written from a `StatementBundle` carries no scheme — the bundle has
326
+ no field for one — and calling a ledger's entity an SEC CIK because that is
327
+ the model's default is a false statement about the report. A ten-digit
328
+ identifier is a CIK; anything else is read under the neutral entity scheme,
329
+ which is the same convention the OIM-family projections write it under.
330
+ """
331
+ digits = identifier.isdigit() and len(identifier) == 10
332
+ return CIK_SCHEME if digits else ENTITY_SCHEME
333
+
334
+
320
335
  def _filing(
321
336
  nodes: Sequence[Mapping[str, Any]],
322
337
  entity: EntityIdentity,
@@ -197,7 +197,7 @@ def _read(document: Mapping[str, Any]) -> tuple[XbrlModel, ImportGaps]:
197
197
 
198
198
  entity = _entity(xbrl_model, namespaces)
199
199
  concepts = _concepts(xbrl_model, namespaces, gaps)
200
- _apply_labels(xbrl_model, concepts, entity, gaps)
200
+ _apply_labels(xbrl_model, concepts, entity, _entity_sqname(xbrl_model), gaps)
201
201
  networks = _networks(xbrl_model)
202
202
  facts, periods, units = _facts(xbrl_model, concepts, entity, namespaces, gaps)
203
203
  _mark_text_facts(concepts, facts)
@@ -220,12 +220,17 @@ def _read(document: Mapping[str, Any]) -> tuple[XbrlModel, ImportGaps]:
220
220
  # -- identity -------------------------------------------------------------------
221
221
 
222
222
 
223
+ def _entity_sqname(xbrl_model: Mapping[str, Any]) -> str:
224
+ """The entity object's name, as the document wrote it."""
225
+ entities = _sequence(xbrl_model.get("entities"))
226
+ return str(_mapping(entities[0]).get("name", "")) if entities else ""
227
+
228
+
223
229
  def _entity(
224
230
  xbrl_model: Mapping[str, Any], namespaces: Mapping[str, str]
225
231
  ) -> EntityIdentity:
226
232
  """The reporting entity from its SQName — scheme first, identifier second."""
227
- entities = _sequence(xbrl_model.get("entities"))
228
- name = str(_mapping(entities[0]).get("name", "")) if entities else ""
233
+ name = _entity_sqname(xbrl_model)
229
234
  prefix, _, identifier = name.partition(":")
230
235
  if not identifier:
231
236
  prefix, identifier = "", name
@@ -438,6 +443,7 @@ def _apply_labels(
438
443
  xbrl_model: Mapping[str, Any],
439
444
  concepts: dict[str, Concept],
440
445
  entity: EntityIdentity,
446
+ entity_sqname: str,
441
447
  gaps: ImportGaps,
442
448
  ) -> None:
443
449
  """Hang each label object on the element it points at.
@@ -446,7 +452,6 @@ def _apply_labels(
446
452
  the networks; a label on the entity is the registrant's name, which is the
447
453
  only place a compiled model carries it.
448
454
  """
449
- entity_name = f"cik:{entity.cik}" if entity.scheme == CIK_SCHEME else None
450
455
  for entry in _sequence(xbrl_model.get("labels")):
451
456
  label = _mapping(entry)
452
457
  target = str(label.get("forObject", ""))
@@ -457,7 +462,7 @@ def _apply_labels(
457
462
  gaps.unmapped_label_types[label_type] = (
458
463
  gaps.unmapped_label_types.get(label_type, 0) + 1
459
464
  )
460
- if target and target == entity_name:
465
+ if target and target == entity_sqname:
461
466
  if entity.name is None and isinstance(value, str):
462
467
  entity.name = value
463
468
  continue
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes