|
118 | 118 | PO_DOCSTRING_LOCATION = re.compile(r":docstring of [a-zA-Z0-9._]+:[0-9]+") |
119 | 119 | XLIFF_FUZZY_STATES = {"new", "needs-translation", "needs-adaptation", "needs-l10n"} |
120 | 120 | _CSV_MAX_PLURAL_FORMS = 100 |
| 121 | +type PoHeaderUnit = pounit | PoXliffUnit |
121 | 122 |
|
122 | 123 |
|
123 | 124 | class CSVMetadataError(ValueError): |
@@ -1542,15 +1543,15 @@ def set_state(self, state) -> None: |
1542 | 1543 | self.unit.marktranslatable(False) |
1543 | 1544 |
|
1544 | 1545 |
|
1545 | | -class PoHeaderMixin[ |
1546 | | - S: pofile | PoXliffFile, |
1547 | | - U: pounit | PoXliffUnit, |
1548 | | - T: TTKitUnit, |
1549 | | -](TTKitFormat[S, U, T]): |
| 1546 | +class PoHeaderMixin: |
| 1547 | + store: pofile | PoXliffFile |
| 1548 | + |
1550 | 1549 | def _po_header_store(self) -> poheader: |
1551 | | - return self.store |
| 1550 | + return cast("poheader", self.store) |
1552 | 1551 |
|
1553 | | - def _ensure_po_header_first(self, header: U | None = None) -> U | None: |
| 1552 | + def _ensure_po_header_first( |
| 1553 | + self, header: PoHeaderUnit | None = None |
| 1554 | + ) -> PoHeaderUnit | None: |
1554 | 1555 | """Keep PO-style header in the position expected by Translate Toolkit.""" |
1555 | 1556 | units = self.store.units |
1556 | 1557 | if header is None: |
@@ -1640,7 +1641,9 @@ def update_header(self, file_format_params: FileFormatParams, **kwargs) -> None: |
1640 | 1641 | self._ensure_po_header_first(store.updateheader(add=True, **kwargs)) |
1641 | 1642 |
|
1642 | 1643 |
|
1643 | | -class BasePoFormat[S: pofile, U: pounit, T: BasePoUnit](PoHeaderMixin[S, U, T]): |
| 1644 | +class BasePoFormat[S: pofile, U: pounit, T: BasePoUnit]( |
| 1645 | + PoHeaderMixin, TTKitFormat[S, U, T] |
| 1646 | +): |
1644 | 1647 | loader = pofile # type: ignore[assignment] |
1645 | 1648 | plural_preference: tuple[int, ...] | None = None |
1646 | 1649 | supports_plural: bool = True |
@@ -1832,10 +1835,7 @@ class RichXliffFormat(XliffFormat): |
1832 | 1835 | unit_class = RichXliffUnit |
1833 | 1836 |
|
1834 | 1837 |
|
1835 | | -class PoXliffFormat( |
1836 | | - PoHeaderMixin[PoXliffFile, PoXliffUnit, XliffUnit[PoXliffUnit, XliffFormat]], |
1837 | | - XliffFormat, |
1838 | | -): |
| 1838 | +class PoXliffFormat(PoHeaderMixin, XliffFormat): |
1839 | 1839 | # Translators: File format name |
1840 | 1840 | name = gettext_lazy("XLIFF 1.2 with gettext extensions") |
1841 | 1841 | format_id = "poxliff" |
|
0 commit comments