Skip to content

Treat @context as a set rather than array#29

Merged
Xarthisius merged 1 commit into
mainfrom
context_as_set
Apr 3, 2026
Merged

Treat @context as a set rather than array#29
Xarthisius merged 1 commit into
mainfrom
context_as_set

Conversation

@Xarthisius
Copy link
Copy Markdown
Contributor

This pull request refactors how extra JSON-LD context is handled throughout the codebase, standardizing it from a list of dicts to a single merged dict. This change simplifies the interface, improves consistency, and ensures that extra context entries are merged rather than appended. The update affects the core model, CLI parsing, and associated tests, with backward compatibility for older data formats.

Core model and serialization changes:

  • The extra_context attribute in TransparentResearchObject is now a dict instead of a list of dicts, and the base context (_JSONLD_CONTEXT) is also a dict. Extra context entries are merged into the base context when serializing to JSON-LD, and extracted appropriately during deserialization, with backward compatibility for list-based contexts. [1] [2] [3] [4]

CLI and facade changes:

  • The CLI flag parsing for --extra-context now produces a single dict (not a list of dicts), and the TRO facade merges extra context entries into the model instead of appending. [1] [2] [3]

Test updates:

  • All tests in tests/test_extra_context.py and tests/test_cli.py are updated to expect and check for dict-based context structures, ensuring correct behavior and compatibility with the new format. [1] [2] [3] [4]

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.08%. Comparing base (49075ca) to head (85c865c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
+ Coverage   95.05%   95.08%   +0.02%     
==========================================
  Files          15       15              
  Lines        1051     1057       +6     
==========================================
+ Hits          999     1005       +6     
  Misses         52       52              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Xarthisius Xarthisius merged commit 95ec41b into main Apr 3, 2026
8 checks passed
@Xarthisius Xarthisius deleted the context_as_set branch April 3, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant