Skip to content

Commit 0364136

Browse files
authored
Minor cleanups (#948)
* Add __all__s to be cleaner about re-exports * Move timezone_getter to conftest * Apply spelling corrections suggested by codespell
1 parent 27380da commit 0364136

16 files changed

Lines changed: 73 additions & 53 deletions

CHANGES.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ Version 1.0
613613
- Explicitly sort instead of using sorted() and don't assume ordering
614614
(Jython compatibility).
615615
- Removed ValueError raising for string formatting message checkers if the
616-
string does not contain any string formattings (:trac:`150`).
616+
string does not contain any string formatting (:trac:`150`).
617617
- Fix Serbian plural forms (:trac:`213`).
618618
- Small speed improvement in format_date() (:trac:`216`).
619619
- Fix so frontend.CommandLineInterface.run does not accumulate logging
@@ -690,7 +690,7 @@ Version 0.9.6
690690
- Explicitly sort instead of using sorted() and don't assume ordering
691691
(Python 2.3 and Jython compatibility).
692692
- Removed ValueError raising for string formatting message checkers if the
693-
string does not contain any string formattings (:trac:`150`).
693+
string does not contain any string formatting (:trac:`150`).
694694
- Fix Serbian plural forms (:trac:`213`).
695695
- Small speed improvement in format_date() (:trac:`216`).
696696
- Fix number formatting for locales where CLDR specifies alt or draft

babel/__init__.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,22 @@
1616
:license: BSD, see LICENSE for more details.
1717
"""
1818

19-
from babel.core import UnknownLocaleError, Locale, default_locale, \
20-
negotiate_locale, parse_locale, get_locale_identifier
21-
19+
from babel.core import (
20+
Locale,
21+
UnknownLocaleError,
22+
default_locale,
23+
get_locale_identifier,
24+
negotiate_locale,
25+
parse_locale,
26+
)
2227

2328
__version__ = '2.11.0'
29+
30+
__all__ = [
31+
'Locale',
32+
'UnknownLocaleError',
33+
'default_locale',
34+
'get_locale_identifier',
35+
'negotiate_locale',
36+
'parse_locale',
37+
]

babel/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ def negotiate(
239239
>>> Locale.negotiate(['de_DE', 'de'], ['en_US'])
240240
241241
You can specify the character used in the locale identifiers to separate
242-
the differnet components. This separator is applied to both lists. Also,
242+
the different components. This separator is applied to both lists. Also,
243243
case is ignored in the comparison:
244244
245245
>>> Locale.negotiate(['de-DE', 'de'], ['en-us', 'de-de'], sep='-')
246246
Locale('de', territory='DE')
247247
248-
:param preferred: the list of locale identifers preferred by the user
248+
:param preferred: the list of locale identifiers preferred by the user
249249
:param available: the list of locale identifiers available
250250
:param aliases: a dictionary of aliases for locale identifiers
251251
"""

babel/dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ def get_week_number(self, day_of_period: int, day_of_week: int | None = None) ->
17571757
17581758
:param day_of_period: the number of the day in the period (usually
17591759
either the day of month or the day of year)
1760-
:param day_of_week: the week day; if ommitted, the week day of the
1760+
:param day_of_week: the week day; if omitted, the week day of the
17611761
current date is assumed
17621762
"""
17631763
if day_of_week is None:

babel/localedata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def load(name: os.PathLike[str] | str, merge_inherited: bool = True) -> dict[str
121121
:param merge_inherited: whether the inherited data should be merged into
122122
the data of the requested locale
123123
:raise `IOError`: if no locale data file is found for the given locale
124-
identifer, or one of the locales it inherits from
124+
identifier, or one of the locales it inherits from
125125
"""
126126
name = os.path.basename(name)
127127
_cache_lock.acquire()

babel/messages/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@
88
:license: BSD, see LICENSE for more details.
99
"""
1010

11-
from babel.messages.catalog import *
11+
from babel.messages.catalog import (
12+
Catalog,
13+
Message,
14+
TranslationError,
15+
)
16+
17+
__all__ = [
18+
"Catalog",
19+
"Message",
20+
"TranslationError",
21+
]

babel/messages/checkers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _validate_format(format: str, alternative: str) -> None:
6767
placeholders if `format` uses named placeholders.
6868
6969
The behavior of this function is undefined if the string does not use
70-
string formattings.
70+
string formatting.
7171
7272
If the string formatting of `alternative` is compatible to `format` the
7373
function returns `None`, otherwise a `TranslationError` is raised.

babel/messages/extract.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ def extract_python(
537537
messages = tuple(messages)
538538
else:
539539
messages = messages[0]
540-
# Comments don't apply unless they immediately preceed the
541-
# message
540+
# Comments don't apply unless they immediately
541+
# precede the message
542542
if translator_comments and \
543543
translator_comments[-1][0] < message_lineno - 1:
544544
translator_comments = []
@@ -673,7 +673,7 @@ def extract_javascript(
673673
break
674674

675675
elif token.type == 'multilinecomment':
676-
# only one multi-line comment may preceed a translation
676+
# only one multi-line comment may precede a translation
677677
translator_comments = []
678678
value = token.value[2:-2].strip()
679679
for comment_tag in comment_tags:

babel/numbers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def is_currency(currency: str, locale: Locale | str | None = None) -> bool:
9393

9494

9595
def normalize_currency(currency: str, locale: Locale | str | None = None) -> str | None:
96-
"""Returns the normalized sting of any currency code.
96+
"""Returns the normalized identifier of any currency code.
9797
9898
Accepts a ``locale`` parameter for fined-grained validation, working as
9999
the one defined above in ``list_currencies()`` method.
@@ -1203,7 +1203,7 @@ def apply(
12031203
self._format_int(
12041204
str(exp), self.exp_prec[0], self.exp_prec[1], locale)])
12051205

1206-
# Is it a siginificant digits pattern?
1206+
# Is it a significant digits pattern?
12071207
elif '@' in self.pattern:
12081208
text = self._format_significant(value,
12091209
self.int_prec[0],

babel/plural.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class _Parser:
425425
'n in 3,5,7..15'.
426426
- Samples are ignored.
427427
428-
The translator parses the expression on instanciation into an attribute
428+
The translator parses the expression on instantiation into an attribute
429429
called `ast`.
430430
"""
431431

0 commit comments

Comments
 (0)