diff options
author | Aarni Koskela <akx@iki.fi> | 2023-01-18 19:47:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-18 19:47:43 +0200 |
commit | 03641361830ce036b89b4f9660ebadfe96e10445 (patch) | |
tree | 3e96c2de2f61f71a5e396e37a08c767be88f65fb /babel | |
parent | 27380daecb325d39ab62deffde7fba8e494cfefd (diff) | |
download | babel-03641361830ce036b89b4f9660ebadfe96e10445.tar.gz |
Minor cleanups (#948)
* Add __all__s to be cleaner about re-exports
* Move timezone_getter to conftest
* Apply spelling corrections suggested by codespell
Diffstat (limited to 'babel')
-rw-r--r-- | babel/__init__.py | 20 | ||||
-rw-r--r-- | babel/core.py | 4 | ||||
-rw-r--r-- | babel/dates.py | 2 | ||||
-rw-r--r-- | babel/localedata.py | 2 | ||||
-rw-r--r-- | babel/messages/__init__.py | 12 | ||||
-rw-r--r-- | babel/messages/checkers.py | 2 | ||||
-rw-r--r-- | babel/messages/extract.py | 6 | ||||
-rw-r--r-- | babel/numbers.py | 4 | ||||
-rw-r--r-- | babel/plural.py | 2 | ||||
-rw-r--r-- | babel/support.py | 2 |
10 files changed, 40 insertions, 16 deletions
diff --git a/babel/__init__.py b/babel/__init__.py index df19003..be35c03 100644 --- a/babel/__init__.py +++ b/babel/__init__.py @@ -16,8 +16,22 @@ :license: BSD, see LICENSE for more details. """ -from babel.core import UnknownLocaleError, Locale, default_locale, \ - negotiate_locale, parse_locale, get_locale_identifier - +from babel.core import ( + Locale, + UnknownLocaleError, + default_locale, + get_locale_identifier, + negotiate_locale, + parse_locale, +) __version__ = '2.11.0' + +__all__ = [ + 'Locale', + 'UnknownLocaleError', + 'default_locale', + 'get_locale_identifier', + 'negotiate_locale', + 'parse_locale', +] diff --git a/babel/core.py b/babel/core.py index 704957b..5041c1b 100644 --- a/babel/core.py +++ b/babel/core.py @@ -239,13 +239,13 @@ class Locale: >>> Locale.negotiate(['de_DE', 'de'], ['en_US']) You can specify the character used in the locale identifiers to separate - the differnet components. This separator is applied to both lists. Also, + the different components. This separator is applied to both lists. Also, case is ignored in the comparison: >>> Locale.negotiate(['de-DE', 'de'], ['en-us', 'de-de'], sep='-') Locale('de', territory='DE') - :param preferred: the list of locale identifers preferred by the user + :param preferred: the list of locale identifiers preferred by the user :param available: the list of locale identifiers available :param aliases: a dictionary of aliases for locale identifiers """ diff --git a/babel/dates.py b/babel/dates.py index 05cfa25..51bc7ff 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -1757,7 +1757,7 @@ class DateTimeFormat: :param day_of_period: the number of the day in the period (usually either the day of month or the day of year) - :param day_of_week: the week day; if ommitted, the week day of the + :param day_of_week: the week day; if omitted, the week day of the current date is assumed """ if day_of_week is None: diff --git a/babel/localedata.py b/babel/localedata.py index 0d3508d..c14391a 100644 --- a/babel/localedata.py +++ b/babel/localedata.py @@ -121,7 +121,7 @@ def load(name: os.PathLike[str] | str, merge_inherited: bool = True) -> dict[str :param merge_inherited: whether the inherited data should be merged into the data of the requested locale :raise `IOError`: if no locale data file is found for the given locale - identifer, or one of the locales it inherits from + identifier, or one of the locales it inherits from """ name = os.path.basename(name) _cache_lock.acquire() diff --git a/babel/messages/__init__.py b/babel/messages/__init__.py index ad4fd34..60aeba0 100644 --- a/babel/messages/__init__.py +++ b/babel/messages/__init__.py @@ -8,4 +8,14 @@ :license: BSD, see LICENSE for more details. """ -from babel.messages.catalog import * +from babel.messages.catalog import ( + Catalog, + Message, + TranslationError, +) + +__all__ = [ + "Catalog", + "Message", + "TranslationError", +] diff --git a/babel/messages/checkers.py b/babel/messages/checkers.py index 9231c67..00b84e5 100644 --- a/babel/messages/checkers.py +++ b/babel/messages/checkers.py @@ -67,7 +67,7 @@ def _validate_format(format: str, alternative: str) -> None: placeholders if `format` uses named placeholders. The behavior of this function is undefined if the string does not use - string formattings. + string formatting. If the string formatting of `alternative` is compatible to `format` the function returns `None`, otherwise a `TranslationError` is raised. diff --git a/babel/messages/extract.py b/babel/messages/extract.py index 5c331c0..a426510 100644 --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -537,8 +537,8 @@ def extract_python( messages = tuple(messages) else: messages = messages[0] - # Comments don't apply unless they immediately preceed the - # message + # Comments don't apply unless they immediately + # precede the message if translator_comments and \ translator_comments[-1][0] < message_lineno - 1: translator_comments = [] @@ -673,7 +673,7 @@ def extract_javascript( break elif token.type == 'multilinecomment': - # only one multi-line comment may preceed a translation + # only one multi-line comment may precede a translation translator_comments = [] value = token.value[2:-2].strip() for comment_tag in comment_tags: diff --git a/babel/numbers.py b/babel/numbers.py index 95e9d2a..5a05f91 100644 --- a/babel/numbers.py +++ b/babel/numbers.py @@ -93,7 +93,7 @@ def is_currency(currency: str, locale: Locale | str | None = None) -> bool: def normalize_currency(currency: str, locale: Locale | str | None = None) -> str | None: - """Returns the normalized sting of any currency code. + """Returns the normalized identifier of any currency code. Accepts a ``locale`` parameter for fined-grained validation, working as the one defined above in ``list_currencies()`` method. @@ -1203,7 +1203,7 @@ class NumberPattern: self._format_int( str(exp), self.exp_prec[0], self.exp_prec[1], locale)]) - # Is it a siginificant digits pattern? + # Is it a significant digits pattern? elif '@' in self.pattern: text = self._format_significant(value, self.int_prec[0], diff --git a/babel/plural.py b/babel/plural.py index efd0f1f..b4f54c0 100644 --- a/babel/plural.py +++ b/babel/plural.py @@ -425,7 +425,7 @@ class _Parser: 'n in 3,5,7..15'. - Samples are ignored. - The translator parses the expression on instanciation into an attribute + The translator parses the expression on instantiation into an attribute called `ast`. """ diff --git a/babel/support.py b/babel/support.py index da111fc..a8dd230 100644 --- a/babel/support.py +++ b/babel/support.py @@ -418,7 +418,7 @@ class NullTranslations(gettext.NullTranslations): # backward compatibility with 0.9 dungettext = udngettext - # Most of the downwards code, until it get's included in stdlib, from: + # Most of the downwards code, until it gets included in stdlib, from: # https://bugs.python.org/file10036/gettext-pgettext.patch # # The encoding of a msgctxt and a msgid in a .mo file is |