Skip to content

Commit c30af80

Browse files
authored
Merge pull request #1017 from python-babel/renovate
Renovate lint tools
2 parents 7ef7300 + fe186e0 commit c30af80

File tree

9 files changed

+49
-30
lines changed

9 files changed

+49
-30
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: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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/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/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))]

scripts/import_cldr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,25 +525,25 @@ def parse_dates(data, tree, sup, regions, territory):
525525
if _should_skip_elem(elem):
526526
continue
527527
territories = elem.attrib['territories'].split()
528-
if territory in territories or any([r in territories for r in regions]):
528+
if territory in territories or any(r in territories for r in regions):
529529
week_data['min_days'] = int(elem.attrib['count'])
530530
for elem in supelem.findall('firstDay'):
531531
if _should_skip_elem(elem):
532532
continue
533533
territories = elem.attrib['territories'].split()
534-
if territory in territories or any([r in territories for r in regions]):
534+
if territory in territories or any(r in territories for r in regions):
535535
week_data['first_day'] = weekdays[elem.attrib['day']]
536536
for elem in supelem.findall('weekendStart'):
537537
if _should_skip_elem(elem):
538538
continue
539539
territories = elem.attrib['territories'].split()
540-
if territory in territories or any([r in territories for r in regions]):
540+
if territory in territories or any(r in territories for r in regions):
541541
week_data['weekend_start'] = weekdays[elem.attrib['day']]
542542
for elem in supelem.findall('weekendEnd'):
543543
if _should_skip_elem(elem):
544544
continue
545545
territories = elem.attrib['territories'].split()
546-
if territory in territories or any([r in territories for r in regions]):
546+
if territory in territories or any(r in territories for r in regions):
547547
week_data['weekend_end'] = weekdays[elem.attrib['day']]
548548
zone_formats = data.setdefault('zone_formats', {})
549549
for elem in tree.findall('.//timeZoneNames/gmtFormat'):

tests/messages/test_catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def test_catalog_update():
455455
assert len(cat) == 3
456456

457457
msg1 = cat['green']
458-
msg1.string
458+
assert not msg1.string
459459
assert msg1.locations == [('main.py', 99)]
460460

461461
msg2 = cat['blue']

tests/test_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def raise_attribute_error():
291291

292292
proxy = support.LazyProxy(raise_attribute_error)
293293
with pytest.raises(AttributeError) as exception:
294-
proxy.value
294+
_ = proxy.value
295295

296296
assert str(exception.value) == 'message'
297297

0 commit comments

Comments
 (0)