Skip to content

Commit

Permalink
Fix mypy errors on Windows (#12266)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner authored Apr 11, 2024
1 parent 5bec029 commit 8ee9c53
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ lint = [
"sphinx-lint",
"types-docutils",
"types-requests",
"importlib_metadata", # for mypy (Python<=3.9)
"tomli", # for mypy (Python<=3.10)
"pytest>=6.0",
]
test = [
Expand Down
15 changes: 9 additions & 6 deletions sphinx/locale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import locale
import sys
from gettext import NullTranslations, translation
from os import path
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -156,13 +157,15 @@ def init_console(
"""
if locale_dir is None:
locale_dir = _LOCALE_DIR
try:
# encoding is ignored
language, _ = locale.getlocale(locale.LC_MESSAGES)
except AttributeError:
# LC_MESSAGES is not always defined. Fallback to the default language
# in case it is not.
if sys.platform == 'win32':
language = None
else:
try:
# encoding is ignored
language, _ = locale.getlocale(locale.LC_MESSAGES)
except AttributeError:
# Fallback to the default language in case LC_MESSAGES is not defined.
language = None
return init([locale_dir], language, catalog, 'console')


Expand Down
2 changes: 1 addition & 1 deletion sphinx/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if sys.version_info >= (3, 10):
from importlib.metadata import entry_points
else:
from importlib_metadata import entry_points # type: ignore[import-not-found]
from importlib_metadata import entry_points

from sphinx.domains import Domain, Index, ObjType
from sphinx.domains.std import GenericObject, Target
Expand Down
4 changes: 2 additions & 2 deletions sphinx/theming.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib # type: ignore[import-not-found]
import tomli as tomllib

if sys.version_info >= (3, 10):
from importlib.metadata import entry_points
else:
from importlib_metadata import entry_points # type: ignore[import-not-found]
from importlib_metadata import entry_points

if TYPE_CHECKING:
from typing import TypedDict
Expand Down

0 comments on commit 8ee9c53

Please sign in to comment.