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 functools import cached_property
from itertools import groupby
from typing import Protocol
import sentry_sdk
from django.db import DatabaseError, transaction
@@ -124,6 +125,15 @@ class RecoverableSyncError(BaseSyncError):
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'))
@@ -299,14 +309,14 @@ class OutboundSyncProvider:
def sync_object_with_properties(
self,
external_id_field,
external_id_field: str,
id_value,
properties: list,
inputs: dict,
mapping,
mapping: ObjectMapping,
mapped_objects: dict,
**kwargs,
):
) -> dict:
"""
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.