Skip to content

v0.6.2 - Python FhirProto Bug Fixes and Performance Improvements

Compare
Choose a tag to compare
@Cam2337 Cam2337 released this 28 Oct 00:29
· 666 commits to master since this release

This release adds several bug fixes for the Python release of FhirProto in addition to some quality-of-life and performance improvements.

Python FhirProto Bug Fixes

Analytic FHIR primitive printing

We discovered that leveraging the json_format.py module for analytic printing would result in an AttributeError exception being thrown. The bug has been corrected and additional test coverage has been added to ensure that Analytic FHIR is tested in all offered versions of the FHIR standard (at time of writing, STU3 and R4).

"Distant future" timezone-aware arithmetic

Previously, the internal module _primitive_time_utils.py leveraged dateutil for datetime.datetime timezone arithmetic. However, dateutil is unable to properly account for DST offsets when performing datetime arithmetic for dates in the distant future. This is a known dateutil bug and more info can be found at:

This is addressed with PEP615 for Python interpreters >=3.9. backports.zoneinfo provides backwards compatibility for interpreters >=3.6, < 3.9, which we now leverage.

Python Performance Improvements

Minor performance improvements in PrimitiveWrapper construction were added via dict-lookup for primitive wrapper class. Additionally, a fix was made in annotation_utils.py to avoid linear attribute access when retrieving options from a Descriptor for C++-based protos (which we default to in both bazel and pypi).

Additional Python QoL Improvements

  • Added .pyi annotation stubs for generated proto classes, and py.typed file for the google-fhir package per PEP0561.
  • Added additional safety checks during testing to ensure integrity of protos during printing (specifically since some print styles, e.g. ANALYTIC, require mutation)