Skip to content

Commit

Permalink
locale: put all the imports together at the top (#10860)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Oct 8, 2023
1 parent a042be6 commit c47be69
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extra_standard_library = [
"_heapq",
"_imp",
"_json",
"_locale",
"_markupbase",
"_msi",
"_operator",
Expand Down
81 changes: 40 additions & 41 deletions stdlib/locale.pyi
Original file line number Diff line number Diff line change
@@ -1,40 +1,4 @@
import sys
from collections.abc import Callable

__all__ = [
"getlocale",
"getdefaultlocale",
"getpreferredencoding",
"Error",
"setlocale",
"resetlocale",
"localeconv",
"strcoll",
"strxfrm",
"str",
"atof",
"atoi",
"format_string",
"currency",
"normalize",
"LC_CTYPE",
"LC_COLLATE",
"LC_TIME",
"LC_MONETARY",
"LC_NUMERIC",
"LC_ALL",
"CHAR_MAX",
]

if sys.version_info >= (3, 11):
__all__ += ["getencoding"]

if sys.version_info < (3, 12):
__all__ += ["format"]

if sys.platform != "win32":
__all__ += ["LC_MESSAGES"]

from _locale import (
CHAR_MAX as CHAR_MAX,
LC_ALL as LC_ALL,
Expand All @@ -49,6 +13,13 @@ from _locale import (
strxfrm as strxfrm,
)

# This module defines a function "str()", which is why "str" can't be used
# as a type annotation or type alias.
from builtins import str as _str
from collections.abc import Callable
from decimal import Decimal
from typing import Any

if sys.version_info >= (3, 11):
from _locale import getencoding as getencoding

Expand Down Expand Up @@ -120,11 +91,39 @@ if sys.platform != "win32":
textdomain as textdomain,
)

# This module defines a function "str()", which is why "str" can't be used
# as a type annotation or type alias.
from builtins import str as _str
from decimal import Decimal
from typing import Any
__all__ = [
"getlocale",
"getdefaultlocale",
"getpreferredencoding",
"Error",
"setlocale",
"resetlocale",
"localeconv",
"strcoll",
"strxfrm",
"str",
"atof",
"atoi",
"format_string",
"currency",
"normalize",
"LC_CTYPE",
"LC_COLLATE",
"LC_TIME",
"LC_MONETARY",
"LC_NUMERIC",
"LC_ALL",
"CHAR_MAX",
]

if sys.version_info >= (3, 11):
__all__ += ["getencoding"]

if sys.version_info < (3, 12):
__all__ += ["format"]

if sys.platform != "win32":
__all__ += ["LC_MESSAGES"]

class Error(Exception): ...

Expand Down

0 comments on commit c47be69

Please sign in to comment.