Skip to content

Commit 620fc1d

Browse files
authored
Merge branch 'master' into joe/updates-ignore-pot-creation-date
2 parents 254a81a + 1747d22 commit 620fc1d

File tree

17 files changed

+72
-52
lines changed

17 files changed

+72
-52
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
2-
- repo: https://github.com/charliermarsh/ruff-pre-commit
3-
rev: v0.0.247
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.0.275
44
hooks:
55
- id: ruff
66
args:

babel/dates.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def _get_tz_name(dt_or_tzinfo: _DtOrTzinfo) -> str:
112112
elif hasattr(tzinfo, 'key') and tzinfo.key is not None: # ZoneInfo object
113113
return tzinfo.key
114114
else:
115-
return tzinfo.tzname(dt or datetime.datetime.utcnow())
115+
return tzinfo.tzname(dt or datetime.datetime.now(UTC))
116116

117117

118118
def _get_datetime(instant: _Instant) -> datetime.datetime:
@@ -147,9 +147,9 @@ def _get_datetime(instant: _Instant) -> datetime.datetime:
147147
:rtype: datetime
148148
"""
149149
if instant is None:
150-
return datetime.datetime.utcnow()
150+
return datetime.datetime.now(UTC).replace(tzinfo=None)
151151
elif isinstance(instant, (int, float)):
152-
return datetime.datetime.utcfromtimestamp(instant)
152+
return datetime.datetime.fromtimestamp(instant, UTC).replace(tzinfo=None)
153153
elif isinstance(instant, datetime.time):
154154
return datetime.datetime.combine(datetime.date.today(), instant)
155155
elif isinstance(instant, datetime.date) and not isinstance(instant, datetime.datetime):
@@ -201,9 +201,9 @@ def _get_time(
201201
:rtype: time
202202
"""
203203
if time is None:
204-
time = datetime.datetime.utcnow()
204+
time = datetime.datetime.now(UTC)
205205
elif isinstance(time, (int, float)):
206-
time = datetime.datetime.utcfromtimestamp(time)
206+
time = datetime.datetime.fromtimestamp(time, UTC)
207207

208208
if time.tzinfo is None:
209209
time = time.replace(tzinfo=UTC)
@@ -538,11 +538,11 @@ def get_timezone_name(
538538
539539
>>> from datetime import time
540540
>>> dt = time(15, 30, tzinfo=get_timezone('America/Los_Angeles'))
541-
>>> get_timezone_name(dt, locale='en_US')
541+
>>> get_timezone_name(dt, locale='en_US') # doctest: +SKIP
542542
u'Pacific Standard Time'
543543
>>> get_timezone_name(dt, locale='en_US', return_zone=True)
544544
'America/Los_Angeles'
545-
>>> get_timezone_name(dt, width='short', locale='en_US')
545+
>>> get_timezone_name(dt, width='short', locale='en_US') # doctest: +SKIP
546546
u'PST'
547547
548548
If this function gets passed only a `tzinfo` object and no concrete
@@ -774,10 +774,10 @@ def format_time(
774774
775775
>>> t = time(15, 30)
776776
>>> format_time(t, format='full', tzinfo=get_timezone('Europe/Paris'),
777-
... locale='fr_FR')
777+
... locale='fr_FR') # doctest: +SKIP
778778
u'15:30:00 heure normale d\u2019Europe centrale'
779779
>>> format_time(t, format='full', tzinfo=get_timezone('US/Eastern'),
780-
... locale='en_US')
780+
... locale='en_US') # doctest: +SKIP
781781
u'3:30:00\u202fPM Eastern Standard Time'
782782
783783
:param time: the ``time`` or ``datetime`` object; if `None`, the current
@@ -922,9 +922,12 @@ def format_timedelta(
922922
if format not in ('narrow', 'short', 'medium', 'long'):
923923
raise TypeError('Format must be one of "narrow", "short" or "long"')
924924
if format == 'medium':
925-
warnings.warn('"medium" value for format param of format_timedelta'
926-
' is deprecated. Use "long" instead',
927-
category=DeprecationWarning)
925+
warnings.warn(
926+
'"medium" value for format param of format_timedelta'
927+
' is deprecated. Use "long" instead',
928+
category=DeprecationWarning,
929+
stacklevel=2,
930+
)
928931
format = 'long'
929932
if isinstance(delta, datetime.timedelta):
930933
seconds = int((delta.days * 86400) + delta.seconds)

babel/lists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def format_list(lst: Sequence[str],
4646
A typical 'and' list for arbitrary placeholders.
4747
eg. "January, February, and March"
4848
* standard-short:
49-
A short version of a 'and' list, suitable for use with short or abbreviated placeholder values.
49+
A short version of an 'and' list, suitable for use with short or abbreviated placeholder values.
5050
eg. "Jan., Feb., and Mar."
5151
* or:
5252
A typical 'or' list for arbitrary placeholders.

babel/messages/checkers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ def _check_positional(results: list[tuple[str, str]]) -> bool:
148148
if name not in type_map:
149149
raise TranslationError(f'unknown named placeholder {name!r}')
150150
elif not _compatible(typechar, type_map[name]):
151-
raise TranslationError('incompatible format for '
152-
'placeholder %r: '
153-
'%r and %r are not compatible' %
154-
(name, typechar, type_map[name]))
151+
raise TranslationError(
152+
f'incompatible format for placeholder {name!r}: '
153+
f'{typechar!r} and {type_map[name]!r} are not compatible'
154+
)
155155

156156

157157
def _find_checkers() -> list[Callable[[Catalog | None, Message], object]]:

babel/messages/plurals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class _PluralTuple(tuple):
213213
The number of plurals used by the locale.""")
214214
plural_expr = property(itemgetter(1), doc="""
215215
The plural expression used by the locale.""")
216-
plural_forms = property(lambda x: 'nplurals=%s; plural=%s;' % x, doc="""
216+
plural_forms = property(lambda x: 'nplurals={}; plural={};'.format(*x), doc="""
217217
The plural expression used by the catalog or locale.""")
218218

219219
def __str__(self) -> str:

babel/numbers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def format_number(number: float | decimal.Decimal | str, locale: Locale | str |
400400
401401
402402
"""
403-
warnings.warn('Use babel.numbers.format_decimal() instead.', DeprecationWarning)
403+
warnings.warn('Use babel.numbers.format_decimal() instead.', DeprecationWarning, stacklevel=2)
404404
return format_decimal(number, locale=locale)
405405

406406

@@ -1190,7 +1190,11 @@ def apply(
11901190
# currency's if necessary.
11911191
if force_frac:
11921192
# TODO (3.x?): Remove this parameter
1193-
warnings.warn('The force_frac parameter to NumberPattern.apply() is deprecated.', DeprecationWarning)
1193+
warnings.warn(
1194+
'The force_frac parameter to NumberPattern.apply() is deprecated.',
1195+
DeprecationWarning,
1196+
stacklevel=2,
1197+
)
11941198
frac_prec = force_frac
11951199
elif currency and currency_digits:
11961200
frac_prec = (get_currency_precision(currency), ) * 2

babel/plural.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
def extract_operands(source: float | decimal.Decimal) -> tuple[decimal.Decimal | int, int, int, int, int, int, Literal[0], Literal[0]]:
2525
"""Extract operands from a decimal, a float or an int, according to `CLDR rules`_.
2626
27-
The result is a 8-tuple (n, i, v, w, f, t, c, e), where those symbols are as follows:
27+
The result is an 8-tuple (n, i, v, w, f, t, c, e), where those symbols are as follows:
2828
2929
====== ===============================================================
3030
Symbol Value

babel/support.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,11 @@ def ldgettext(self, domain: str, message: str) -> str:
393393
domain.
394394
"""
395395
import warnings
396-
warnings.warn('ldgettext() is deprecated, use dgettext() instead',
397-
DeprecationWarning, 2)
396+
warnings.warn(
397+
'ldgettext() is deprecated, use dgettext() instead',
398+
DeprecationWarning,
399+
stacklevel=2,
400+
)
398401
return self._domains.get(domain, self).lgettext(message)
399402

400403
def udgettext(self, domain: str, message: str) -> str:
@@ -416,8 +419,11 @@ def ldngettext(self, domain: str, singular: str, plural: str, num: int) -> str:
416419
domain.
417420
"""
418421
import warnings
419-
warnings.warn('ldngettext() is deprecated, use dngettext() instead',
420-
DeprecationWarning, 2)
422+
warnings.warn(
423+
'ldngettext() is deprecated, use dngettext() instead',
424+
DeprecationWarning,
425+
stacklevel=2,
426+
)
421427
return self._domains.get(domain, self).lngettext(singular, plural, num)
422428

423429
def udngettext(self, domain: str, singular: str, plural: str, num: int) -> str:
@@ -458,8 +464,11 @@ def lpgettext(self, context: str, message: str) -> str | bytes | object:
458464
``bind_textdomain_codeset()``.
459465
"""
460466
import warnings
461-
warnings.warn('lpgettext() is deprecated, use pgettext() instead',
462-
DeprecationWarning, 2)
467+
warnings.warn(
468+
'lpgettext() is deprecated, use pgettext() instead',
469+
DeprecationWarning,
470+
stacklevel=2,
471+
)
463472
tmsg = self.pgettext(context, message)
464473
encoding = getattr(self, "_output_charset", None) or locale.getpreferredencoding()
465474
return tmsg.encode(encoding) if isinstance(tmsg, str) else tmsg
@@ -493,8 +502,11 @@ def lnpgettext(self, context: str, singular: str, plural: str, num: int) -> str
493502
``bind_textdomain_codeset()``.
494503
"""
495504
import warnings
496-
warnings.warn('lnpgettext() is deprecated, use npgettext() instead',
497-
DeprecationWarning, 2)
505+
warnings.warn(
506+
'lnpgettext() is deprecated, use npgettext() instead',
507+
DeprecationWarning,
508+
stacklevel=2,
509+
)
498510
ctxt_msg_id = self.CONTEXT_ENCODING % (context, singular)
499511
try:
500512
tmsg = self._catalog[(ctxt_msg_id, self.plural(num))]

babel/units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_unit_name(
5050

5151
def _find_unit_pattern(unit_id: str, locale: Locale | str | None = LC_NUMERIC) -> str | None:
5252
"""
53-
Expand an unit into a qualified form.
53+
Expand a unit into a qualified form.
5454
5555
Known units can be found in the CLDR Unit Validity XML file:
5656
https://unicode.org/repos/cldr/tags/latest/common/validity/unit.xml

contrib/babel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/**
1717
* A simple module that provides a gettext like translation interface.
18-
* The catalog passed to load() must be a object conforming to this
18+
* The catalog passed to load() must be an object conforming to this
1919
* interface::
2020
*
2121
* {

0 commit comments

Comments
 (0)