Skip to content

Commit cd85cea

Browse files
committed
refactor(i18n): improve type hints in i18n handling
1 parent 18e0b2d commit cd85cea

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/flask_wtf/i18n.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Optional
2+
13
from babel import support
24
from flask import current_app
35
from flask import request
@@ -7,7 +9,7 @@
79
__all__ = ("Translations", "translations")
810

911

10-
def _get_translations():
12+
def _get_translations() -> Optional[support.Translations]:
1113
"""Returns the correct gettext translations.
1214
Copy from flask-babel with some modifications.
1315
"""
@@ -31,11 +33,11 @@ def _get_translations():
3133

3234

3335
class Translations:
34-
def gettext(self, string):
36+
def gettext(self, string: str) -> str:
3537
t = _get_translations()
3638
return string if t is None else t.ugettext(string)
3739

38-
def ngettext(self, singular, plural, n):
40+
def ngettext(self, singular: str, plural: str, n: int) -> str:
3941
t = _get_translations()
4042

4143
if t is None:

0 commit comments

Comments
 (0)