• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eclipse-aascw / aas-core-codegen / 35243962401

17 Sep 2026 04:01PM UTC coverage: 85.63% (-0.006%) from 85.636%
35243962401

push

github

web-flow
Compose the Python JSON de-serialization (#706)

Five sixths of the generated ``jsonization.py`` was de-serialization,
and a class cost four constructs there: a ``_SetterFor<Cls>`` class, a
field on it per property, a twelve-line ``set_<prop>_from_jsonable``
method whose body was a single assignment, and a
``_SETTER_MAP_FOR_<CLS>`` of bound methods. Every
``<cls>_from_jsonable`` then re-emitted the same framing around the
property loop, and every dispatching function was the same twenty lines
with two tokens substituted in. The property loop now assigns straight
into the locals which the constructor is called with, the way the C#, Go
and Java generators already do:

    def blob_from_jsonable(jsonable):
        mapping = _as_mapping(jsonable)

        model_type = mapping.get('modelType', None)
        if model_type != 'Blob':
            raise DeserializationException(
                f"Expected modelType to be 'Blob', "
                f"but got: {model_type!r}"
            )

        the_value: Optional[bytes] = None
        the_content_type: Optional[str] = None
        ...

        try:
            for key, jsonable_value in mapping.items():
                if key == 'modelType':
                    # The model type has already been checked above.
                    pass
                elif key == 'value':
                    the_value = _bytes_from_jsonable(jsonable_value)
                ...
                else:
                    raise DeserializationException(
                        f"Unexpected property: {key}"
                    )
        except DeserializationException as exception:
            exception.path._prepend(PropertySegment(mapping, key))
            raise

The rationale and the design:

* The loop is generated per class because a shared one cannot write its
  caller's locals. That is the only reason ``_SetterFor<Cls>`` existed,
  and it cost an object allocated for every instance, a field
  initialised for every property, ... (continued)

215 of 230 new or added lines in 3 files covered. (93.48%)

2 existing lines in 1 file now uncovered.

34215 of 39957 relevant lines covered (85.63%)

2.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.9
/aas_core_codegen/python/common.py


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc