(self, read_context)
| 643 | write_context.try_flush() |
| 644 | |
| 645 | def read(self, read_context): |
| 646 | if read_context.policy is not DEFAULT_POLICY: |
| 647 | read_context.policy.authorize_instantiation(self.type_) |
| 648 | if not self.type_resolver.compatible: |
| 649 | hash_ = read_context.read_int32() |
| 650 | if hash_ != self._hash: |
| 651 | raise TypeNotCompatibleError( |
| 652 | f"Hash {hash_} is not consistent with {self._hash} for type {self.type_}", |
| 653 | ) |
| 654 | obj = self.type_.__new__(self.type_) |
| 655 | read_context.reference(obj) |
| 656 | obj_dict = obj.__dict__ if not self._has_slots else None |
| 657 | if self._has_missing_fields: |
| 658 | for index, field_name in enumerate(self._field_names): |
| 659 | serializer = self._serializers[index] |
| 660 | is_nullable = self._nullable_fields.get(field_name, False) |
| 661 | is_dynamic = self._dynamic_fields.get(field_name, False) |
| 662 | is_tracking_ref = self._ref_fields.get(field_name, False) |
| 663 | is_basic = self._basic_field_flags[index] |
| 664 | is_compatible_scalar_field = self._compatible_scalar_field_flags[index] |
| 665 | if field_name not in self._current_class_field_names or not self._assign_fields[index]: |
| 666 | self._read_missing_field_value( |
| 667 | read_context, |
| 668 | serializer, |
| 669 | is_nullable, |
| 670 | is_dynamic, |
| 671 | is_basic, |
| 672 | is_tracking_ref, |
| 673 | is_compatible_scalar_field, |
| 674 | ) |
| 675 | continue |
| 676 | field_value = self._read_field_value( |
| 677 | read_context, |
| 678 | serializer, |
| 679 | is_nullable, |
| 680 | is_dynamic, |
| 681 | is_basic, |
| 682 | is_tracking_ref, |
| 683 | is_compatible_scalar_field, |
| 684 | ) |
| 685 | validation_field_type = self._validation_field_types[index] |
| 686 | if validation_field_type is None: |
| 687 | interned_name = self._field_name_interned[field_name] |
| 688 | if obj_dict is not None: |
| 689 | obj_dict[interned_name] = field_value |
| 690 | else: |
| 691 | setattr(obj, interned_name, field_value) |
| 692 | else: |
| 693 | self._assign_read_field_value(obj, obj_dict, field_name, field_value, validation_field_type) |
| 694 | else: |
| 695 | if not self._has_validation_fields: |
| 696 | for index, field_name in enumerate(self._field_names): |
| 697 | serializer = self._serializers[index] |
| 698 | is_nullable = self._nullable_fields.get(field_name, False) |
| 699 | is_dynamic = self._dynamic_fields.get(field_name, False) |
| 700 | is_tracking_ref = self._ref_fields.get(field_name, False) |
| 701 | is_basic = self._basic_field_flags[index] |
| 702 | is_compatible_scalar_field = self._compatible_scalar_field_flags[index] |
nothing calls this directly
no test coverage detected