add protocol for object mapping type, declare types of sync_object_with_properties parameters

This commit is contained in:
Mira Weller
2025-07-01 14:06:35 +02:00
parent 9a2464db17
commit 41fcc2a606

View File

@@ -26,6 +26,7 @@ from collections import namedtuple
from datetime import timedelta from datetime import timedelta
from functools import cached_property from functools import cached_property
from itertools import groupby from itertools import groupby
from typing import Protocol
import sentry_sdk import sentry_sdk
from django.db import DatabaseError, transaction from django.db import DatabaseError, transaction
@@ -124,6 +125,15 @@ class RecoverableSyncError(BaseSyncError):
pass pass
class ObjectMapping(Protocol):
id: int
pretix_model: str
external_object_type: str
pretix_id_field: str
external_id_field: str
property_mappings: str
StaticMapping = namedtuple('StaticMapping', ('id', 'pretix_model', 'external_object_type', 'pretix_id_field', 'external_id_field', 'property_mappings')) StaticMapping = namedtuple('StaticMapping', ('id', 'pretix_model', 'external_object_type', 'pretix_id_field', 'external_id_field', 'property_mappings'))
@@ -299,14 +309,14 @@ class OutboundSyncProvider:
def sync_object_with_properties( def sync_object_with_properties(
self, self,
external_id_field, external_id_field: str,
id_value, id_value,
properties: list, properties: list,
inputs: dict, inputs: dict,
mapping, mapping: ObjectMapping,
mapped_objects: dict, mapped_objects: dict,
**kwargs, **kwargs,
): ) -> dict:
""" """
This method is called for each object that needs to be created/updated in the external system -- which these are is This method is called for each object that needs to be created/updated in the external system -- which these are is
determined by the implementation of the `mapping` property. determined by the implementation of the `mapping` property.