summaryrefslogtreecommitdiff
path: root/babel/messages/mofile.py
diff options
context:
space:
mode:
Diffstat (limited to 'babel/messages/mofile.py')
-rw-r--r--babel/messages/mofile.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/babel/messages/mofile.py b/babel/messages/mofile.py
index 8284574..a96f059 100644
--- a/babel/messages/mofile.py
+++ b/babel/messages/mofile.py
@@ -7,18 +7,22 @@
:copyright: (c) 2013-2022 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
+from __future__ import annotations
import array
import struct
+from typing import TYPE_CHECKING
from babel.messages.catalog import Catalog, Message
+if TYPE_CHECKING:
+ from _typeshed import SupportsRead, SupportsWrite
-LE_MAGIC = 0x950412de
-BE_MAGIC = 0xde120495
+LE_MAGIC: int = 0x950412de
+BE_MAGIC: int = 0xde120495
-def read_mo(fileobj):
+def read_mo(fileobj: SupportsRead[bytes]) -> Catalog:
"""Read a binary MO file from the given file-like object and return a
corresponding `Catalog` object.
@@ -102,7 +106,7 @@ def read_mo(fileobj):
return catalog
-def write_mo(fileobj, catalog, use_fuzzy=False):
+def write_mo(fileobj: SupportsWrite[bytes], catalog: Catalog, use_fuzzy: bool = False) -> None:
"""Write a catalog to the specified file-like object using the GNU MO file
format.