API: add python client option (fhirpy|none), default fhirpy; deprecate fhirpyClient#187
Merged
Conversation
…kers fhirpy AsyncFHIRClient is generic over TResource, bound to a ResourceProtocol with a settable resourceType. snake_case models expose the discriminator as resource_type (alias resourceType) and only set resourceType at runtime via __pydantic_init_subclass__, which mypy cannot see. Declare a TYPE_CHECKING-only settable instance annotation (resourceType: str = "") so the models satisfy the protocol bound and class access, with no runtime change.
Replace the boolean fhirpyClient with client: "fhirpy" | "none" on .python({}).
client wins; fhirpyClient is the deprecated fallback (logs a warning, still translated);
the default is now "fhirpy". Add tests for the default, "none", and the deprecated path.
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.
Generator/library change extracted from the python-fhirpy-default work (per review): introduce a
clientoption for the Python generator and makefhirpythe default, plus a type-checking fix for fhirpy + snake_case models..python({ client })Replace the boolean
fhirpyClientwith:"fhirpy"— models extendFhirpyBaseModel(fhirpyAsyncFHIRClientcompatible)."none"— plain Pydantic models, no client-specific code.fhirpyClientis kept and@deprecated— it still works (logs a one-line warning and is translated:true→"fhirpy",false→"none"). Explicitclientwins."fhirpy"— callers that want plain models opt in withclient: "none".fhirpy + snake_case type-checking fix
FhirpyBaseModelnow declares aTYPE_CHECKING-only settableresourceType: str = "". fhirpy'sTResourceis bound to aResourceProtocolwith a settableresourceType; snake_case models expose the discriminator asresource_type(aliasresourceType) and only setresourceTypeat runtime via__pydantic_init_subclass__, which mypy can't see — so fhirpy calls failed type-checking. The annotation is settable (satisfies the protocol bound + class access), defaulted (so the pydantic mypy plugin treats it as optional, not a required ctor arg), and runtime-invisible.Tests
client: "none") to keep testing plain generation.FhirpyBaseModel+fhirpy_base_model.pypresent),"none"→ plain (absent), deprecatedfhirpyClient: true→ fhirpy.tsc+ biome clean; no snapshot changes.Foundation for the example PRs (#185 / #186); merges independently to
main.