Skip to content

Commit 68efee8

Browse files
committed
Add fast paths in python_format and python_brace_format
1 parent edd9cab commit 68efee8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

babel/messages/catalog.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ def python_format(self) -> bool:
289289
290290
:type: `bool`"""
291291
ids = self.id
292-
if not isinstance(ids, (list, tuple)):
293-
ids = [ids]
294-
return any(PYTHON_FORMAT.search(id) for id in ids)
292+
if isinstance(ids, (list, tuple)):
293+
return any(PYTHON_FORMAT.search(id) for id in ids)
294+
return bool(PYTHON_FORMAT.search(ids))
295295

296296
@property
297297
def python_brace_format(self) -> bool:
@@ -304,9 +304,9 @@ def python_brace_format(self) -> bool:
304304
305305
:type: `bool`"""
306306
ids = self.id
307-
if not isinstance(ids, (list, tuple)):
308-
ids = [ids]
309-
return any(_has_python_brace_format(id) for id in ids)
307+
if isinstance(ids, (list, tuple)):
308+
return any(_has_python_brace_format(id) for id in ids)
309+
return _has_python_brace_format(ids)
310310

311311

312312
class TranslationError(Exception):

0 commit comments

Comments
 (0)