Skip to content

Permissiblevalue enums (part 4): Pydanticgen - schema-element.generated-class registry#3600

Draft
noelmcloughlin wants to merge 5 commits into
linkml:mainfrom
noelmcloughlin:permissiblevalue_enum-phase4
Draft

Permissiblevalue enums (part 4): Pydanticgen - schema-element.generated-class registry#3600
noelmcloughlin wants to merge 5 commits into
linkml:mainfrom
noelmcloughlin:permissiblevalue_enum-phase4

Conversation

@noelmcloughlin

Copy link
Copy Markdown
Contributor

Wait for #3596, #3597, #3598, #3599

Summary

Architectural fixes #723 (part 4 of 4)

Before - The registry only works for pythongen output. Pydantic users (SSSOM-py, etc.) emit stdlib class X(str, Enum) enums, which never touched EnumDefinitionImpl._registry, so SchemaView.enum_class_for returned None for any pydantic-generated module.

After - A new module-level helper register_enum_class(schema_id, enum_name, cls) accepts any class object. pydanticgen attaches schema_id to each PydanticEnum, imports the helper, and emits register_enum_class("…", "EnumName", EnumName) lines after the enum block. SchemaView.enum_member_for dispatches on the registered class type - cls(pv) for EnumDefinitionImpl subclasses, cls(pv.text) for stdlib Enum subclasses - so consumers get a uniform SchemaView --> enum class / member lookup regardless of which generator produced the module.

How was this tested?

Added unit tests
Full suite testing

Areas of uncertainty

TBC

Checklist

  • My code follows the contributor guidelines
  • I have added tests that prove my fix/feature works
  • Existing tests pass locally with my changes

AI Assistance

LLM assisted

@noelmcloughlin noelmcloughlin marked this pull request as draft May 30, 2026 19:21
@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.24490% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.69%. Comparing base (d24624c) to head (a544d5b).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
packages/linkml/src/linkml/generators/pythongen.py 5.55% 34 Missing ⚠️
...l/src/linkml/generators/pydanticgen/pydanticgen.py 0.00% 8 Missing ⚠️
...nkml/src/linkml/generators/pydanticgen/template.py 80.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (d24624c) and HEAD (a544d5b). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (d24624c) HEAD (a544d5b)
linkml 6 0
runtime 2 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3600       +/-   ##
===========================================
- Coverage   80.17%   36.69%   -43.49%     
===========================================
  Files         157      157               
  Lines       18679    18726       +47     
  Branches     3935     3948       +13     
===========================================
- Hits        14976     6871     -8105     
- Misses       2868    11637     +8769     
+ Partials      835      218      -617     
Flag Coverage Δ
linkml ?
runtime ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

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.

Clarify how enum slots should be populated in Python code

2 participants