diff --git a/src/gotenberg_client/_base.py b/src/gotenberg_client/_base.py index 3ddf8d3..a9cb260 100644 --- a/src/gotenberg_client/_base.py +++ b/src/gotenberg_client/_base.py @@ -9,6 +9,7 @@ from types import TracebackType from typing import Dict from typing import Optional +from typing import Protocol from typing import Type from typing import Union @@ -28,7 +29,11 @@ class UnreachableCodeError(Exception): pass -class PdfFormatMixin: +class HasFormData(Protocol): + _form_data: Dict[str, str] + + +class PdfFormatMixin(HasFormData): """ https://gotenberg.dev/docs/routes#pdfa-chromium https://gotenberg.dev/docs/routes#pdfa-libreoffice @@ -39,11 +44,11 @@ def pdf_format(self, pdf_format: PdfAFormat) -> Self: All routes provide the option to configure the output PDF as a PDF/A format """ - self._form_data.update(pdf_format.to_form()) # type: ignore[attr-defined,misc] + self._form_data.update(pdf_format.to_form()) return self -class PfdUniversalAccessMixin: +class PfdUniversalAccessMixin(HasFormData): """ https://gotenberg.dev/docs/routes#pdfa-chromium https://gotenberg.dev/docs/routes#pdfa-libreoffice @@ -52,11 +57,11 @@ class PfdUniversalAccessMixin: """ def enable_universal_access(self) -> Self: - self._form_data.update({"pdfua": "true"}) # type: ignore[attr-defined,misc] + self._form_data.update({"pdfua": "true"}) return self def disable_universal_access(self) -> Self: - self._form_data.update({"pdfua": "true"}) # type: ignore[attr-defined,misc] + self._form_data.update({"pdfua": "true"}) return self