Skip to content

Commit

Permalink
Merge pull request #8413 from tk0miya/master
Browse files Browse the repository at this point in the history
Merge 3.x to master (and do isort in master branch again)
  • Loading branch information
tk0miya committed Nov 11, 2020
2 parents 859b5fc + d7783b9 commit 2a26761
Show file tree
Hide file tree
Showing 210 changed files with 407 additions and 603 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
tool: [docslint, flake8, mypy, twine]
tool: [docslint, flake8, isort, mypy, twine]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -66,11 +66,11 @@ doclinter:

.PHONY: test
test:
@$(PYTHON) -m pytest -v $(TEST)
@$(PYTHON) -X dev -m pytest -v $(TEST)

.PHONY: covertest
covertest:
@$(PYTHON) -m pytest -v --cov=sphinx --junitxml=.junit.xml $(TEST)
@$(PYTHON) -X dev -m pytest -v --cov=sphinx --junitxml=.junit.xml $(TEST)

.PHONY: build
build:
Expand Down
1 change: 0 additions & 1 deletion doc/conf.py
Expand Up @@ -4,7 +4,6 @@

import sphinx


extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
'sphinx.ext.autosummary', 'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
Expand Down
3 changes: 1 addition & 2 deletions doc/development/tutorials/examples/recipe.py
Expand Up @@ -4,8 +4,7 @@

from sphinx import addnodes
from sphinx.directives import ObjectDescription
from sphinx.domains import Domain
from sphinx.domains import Index
from sphinx.domains import Domain, Index
from sphinx.roles import XRefRole
from sphinx.util.nodes import make_refnode

Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Expand Up @@ -39,6 +39,9 @@ extension =
paths =
.

[isort]
line_length = 95

[mypy]
python_version = 3.6
disallow_incomplete_defs = True
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Expand Up @@ -43,7 +43,7 @@
],
'lint': [
'flake8>=3.5.0',
'flake8-import-order',
'isort',
'mypy>=0.790',
'docutils-stubs',
],
Expand Down Expand Up @@ -76,9 +76,10 @@ def flush(self):


try:
from babel.messages.pofile import read_po
from babel.messages.frontend import compile_catalog
from json import dump

from babel.messages.frontend import compile_catalog
from babel.messages.pofile import read_po
except ImportError:
pass
else:
Expand Down
1 change: 0 additions & 1 deletion sphinx/__init__.py
Expand Up @@ -19,7 +19,6 @@

from .deprecation import RemovedInNextVersionWarning


# by default, all DeprecationWarning under sphinx package will be emit.
# Users can avoid this by using environment variable: PYTHONWARNINGS=
if 'PYTHONWARNINGS' not in os.environ:
Expand Down
3 changes: 1 addition & 2 deletions sphinx/addnodes.py
Expand Up @@ -8,8 +8,7 @@
:license: BSD, see LICENSE for details.
"""

from typing import Any, Dict, List, Sequence
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict, List, Sequence

from docutils import nodes
from docutils.nodes import Element
Expand Down
13 changes: 6 additions & 7 deletions sphinx/application.py
Expand Up @@ -17,8 +17,7 @@
from collections import deque
from io import StringIO
from os import path
from typing import Any, Callable, Dict, IO, List, Optional, Tuple, Type, Union
from typing import TYPE_CHECKING
from typing import IO, TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Type, Union

from docutils import nodes
from docutils.nodes import Element, TextElement
Expand All @@ -28,7 +27,7 @@
from pygments.lexer import Lexer

import sphinx
from sphinx import package_dir, locale
from sphinx import locale, package_dir
from sphinx.config import Config
from sphinx.domains import Domain, Index
from sphinx.environment import BuildEnvironment
Expand All @@ -42,9 +41,7 @@
from sphinx.registry import SphinxComponentRegistry
from sphinx.roles import XRefRole
from sphinx.theming import Theme
from sphinx.util import docutils
from sphinx.util import logging
from sphinx.util import progress_message
from sphinx.util import docutils, logging, progress_message
from sphinx.util.build_phase import BuildPhase
from sphinx.util.console import bold # type: ignore
from sphinx.util.i18n import CatalogRepository
Expand All @@ -54,6 +51,8 @@
from sphinx.util.typing import RoleFunction, TitleGetter

if TYPE_CHECKING:
from docutils.nodes import Node # NOQA

from sphinx.builders import Builder


Expand Down Expand Up @@ -1068,7 +1067,7 @@ def add_search_language(self, cls: Any) -> None:
.. versionadded:: 1.1
"""
logger.debug('[app] adding search language: %r', cls)
from sphinx.search import languages, SearchLanguage
from sphinx.search import SearchLanguage, languages
assert issubclass(cls, SearchLanguage)
languages[cls.lang] = cls

Expand Down
15 changes: 6 additions & 9 deletions sphinx/builders/__init__.py
Expand Up @@ -11,33 +11,30 @@
import pickle
import time
from os import path
from typing import Any, Dict, Iterable, List, Sequence, Set, Tuple, Type, Union
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Sequence, Set, Tuple, Type, Union

from docutils import nodes
from docutils.nodes import Node

from sphinx.config import Config
from sphinx.environment import BuildEnvironment, CONFIG_OK, CONFIG_CHANGED_REASON
from sphinx.environment import CONFIG_CHANGED_REASON, CONFIG_OK, BuildEnvironment
from sphinx.environment.adapters.asset import ImageAdapter
from sphinx.errors import SphinxError
from sphinx.events import EventManager
from sphinx.io import read_doc
from sphinx.locale import __
from sphinx.util import import_object, logging, rst, progress_message, status_iterator
from sphinx.util import import_object, logging, progress_message, rst, status_iterator
from sphinx.util.build_phase import BuildPhase
from sphinx.util.console import bold # type: ignore
from sphinx.util.docutils import sphinx_domains
from sphinx.util.i18n import CatalogInfo, CatalogRepository, docname_to_domain
from sphinx.util.osutil import SEP, ensuredir, relative_uri, relpath
from sphinx.util.parallel import ParallelTasks, SerialTasks, make_chunks, \
parallel_available
from sphinx.util.parallel import ParallelTasks, SerialTasks, make_chunks, parallel_available
from sphinx.util.tags import Tags

# side effect: registers roles and directives
from sphinx import roles # noqa
from sphinx import directives # noqa

from sphinx import directives # NOQA isort:skip
from sphinx import roles # NOQA isort:skip
try:
import multiprocessing
except ImportError:
Expand Down
5 changes: 2 additions & 3 deletions sphinx/builders/_epub_base.py
Expand Up @@ -22,11 +22,10 @@
from sphinx import addnodes
from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util import status_iterator
from sphinx.util import logging, status_iterator
from sphinx.util.fileutil import copy_asset_file
from sphinx.util.i18n import format_date
from sphinx.util.osutil import ensuredir, copyfile
from sphinx.util.osutil import copyfile, ensuredir

try:
from PIL import Image
Expand Down
4 changes: 1 addition & 3 deletions sphinx/builders/changes.py
Expand Up @@ -10,8 +10,7 @@

import html
from os import path
from typing import Any, Dict, List, Tuple
from typing import cast
from typing import Any, Dict, List, Tuple, cast

from sphinx import package_dir
from sphinx.application import Sphinx
Expand All @@ -24,7 +23,6 @@
from sphinx.util.fileutil import copy_asset_file
from sphinx.util.osutil import ensuredir, os_path


logger = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/epub3.py
Expand Up @@ -16,7 +16,7 @@
from sphinx import package_dir
from sphinx.application import Sphinx
from sphinx.builders import _epub_base
from sphinx.config import Config, ENUM
from sphinx.config import ENUM, Config
from sphinx.locale import __
from sphinx.util import logging, xmlname_checker
from sphinx.util.fileutil import copy_asset_file
Expand Down
15 changes: 7 additions & 8 deletions sphinx/builders/gettext.py
Expand Up @@ -9,28 +9,27 @@
"""

from codecs import open
from collections import defaultdict, OrderedDict
from datetime import datetime, tzinfo, timedelta
from os import path, walk, getenv
from collections import OrderedDict, defaultdict
from datetime import datetime, timedelta, tzinfo
from os import getenv, path, walk
from time import time
from typing import Any, DefaultDict, Dict, Iterable, Generator, List, Set, Tuple, Union
from typing import Any, DefaultDict, Dict, Generator, Iterable, List, Set, Tuple, Union
from uuid import uuid4

from docutils import nodes
from docutils.nodes import Element

from sphinx import addnodes
from sphinx import package_dir
from sphinx import addnodes, package_dir
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.domains.python import pairindextypes
from sphinx.errors import ThemeError
from sphinx.locale import __
from sphinx.util import split_index_msg, logging, status_iterator
from sphinx.util import logging, split_index_msg, status_iterator
from sphinx.util.console import bold # type: ignore
from sphinx.util.i18n import CatalogInfo, docname_to_domain
from sphinx.util.nodes import extract_messages, traverse_translatable_index
from sphinx.util.osutil import ensuredir, canon_path, relpath
from sphinx.util.osutil import canon_path, ensuredir, relpath
from sphinx.util.tags import Tags
from sphinx.util.template import SphinxRenderer

Expand Down
20 changes: 10 additions & 10 deletions sphinx/builders/html/__init__.py
Expand Up @@ -14,7 +14,7 @@
import sys
from datetime import datetime
from os import path
from typing import Any, Dict, IO, Iterable, Iterator, List, Set, Tuple, Type
from typing import IO, Any, Dict, Iterable, Iterator, List, Set, Tuple, Type
from urllib.parse import quote

from docutils import nodes
Expand All @@ -24,10 +24,10 @@
from docutils.nodes import Node
from docutils.utils import relative_path

from sphinx import package_dir, __display_version__
from sphinx import __display_version__, package_dir
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.config import Config, ENUM
from sphinx.config import ENUM, Config
from sphinx.domains import Domain, Index, IndexEntry
from sphinx.environment.adapters.asset import ImageAdapter
from sphinx.environment.adapters.indexentries import IndexEntries
Expand All @@ -37,16 +37,15 @@
from sphinx.locale import _, __
from sphinx.search import js_index
from sphinx.theming import HTMLThemeFactory
from sphinx.util import logging, progress_message, status_iterator, md5
from sphinx.util import logging, md5, progress_message, status_iterator
from sphinx.util.docutils import is_html5_writer_available, new_document
from sphinx.util.fileutil import copy_asset
from sphinx.util.i18n import format_date
from sphinx.util.inventory import InventoryFile
from sphinx.util.matching import patmatch, Matcher, DOTFILES
from sphinx.util.osutil import os_path, relative_uri, ensuredir, movefile, copyfile
from sphinx.util.matching import DOTFILES, Matcher, patmatch
from sphinx.util.osutil import copyfile, ensuredir, movefile, os_path, relative_uri
from sphinx.util.tags import Tags
from sphinx.writers.html import HTMLWriter, HTMLTranslator

from sphinx.writers.html import HTMLTranslator, HTMLWriter

# HTML5 Writer is available or not
if is_html5_writer_available():
Expand Down Expand Up @@ -1184,10 +1183,11 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:
config.html_favicon = None # type: ignore


# for compatibility; RemovedInSphinx40Warning
# for compatibility
import sphinxcontrib.serializinghtml # NOQA

import sphinx.builders.dirhtml # NOQA
import sphinx.builders.singlehtml # NOQA
import sphinxcontrib.serializinghtml # NOQA


def setup(app: Sphinx) -> Dict[str, Any]:
Expand Down
11 changes: 5 additions & 6 deletions sphinx/builders/latex/__init__.py
Expand Up @@ -17,30 +17,29 @@
from docutils.nodes import Node

import sphinx.builders.latex.nodes # NOQA # Workaround: import this before writer to avoid ImportError
from sphinx import package_dir, addnodes, highlighting
from sphinx import addnodes, highlighting, package_dir
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.builders.latex.constants import ADDITIONAL_SETTINGS, DEFAULT_SETTINGS, SHORTHANDOFF
from sphinx.builders.latex.theming import Theme, ThemeFactory
from sphinx.builders.latex.util import ExtBabel
from sphinx.config import Config, ENUM
from sphinx.config import ENUM, Config
from sphinx.deprecation import RemovedInSphinx50Warning
from sphinx.environment.adapters.asset import ImageAdapter
from sphinx.errors import NoUri, SphinxError
from sphinx.locale import _, __
from sphinx.util import texescape, logging, progress_message, status_iterator
from sphinx.util import logging, progress_message, status_iterator, texescape
from sphinx.util.console import bold, darkgreen # type: ignore
from sphinx.util.docutils import SphinxFileOutput, new_document
from sphinx.util.fileutil import copy_asset_file
from sphinx.util.i18n import format_date
from sphinx.util.nodes import inline_all_toctrees
from sphinx.util.osutil import SEP, make_filename_from_project
from sphinx.util.template import LaTeXRenderer
from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator
from sphinx.writers.latex import LaTeXTranslator, LaTeXWriter

# load docutils.nodes after loading sphinx.builders.latex.nodes
from docutils import nodes # NOQA

from docutils import nodes # isort:skip

XINDY_LANG_OPTIONS = {
# language codes from docutils.writers.latex2e.Babel
Expand Down
1 change: 0 additions & 1 deletion sphinx/builders/latex/constants.py
Expand Up @@ -10,7 +10,6 @@

from typing import Any, Dict


PDFLATEX_DEFAULT_FONTPKG = r'''
\usepackage{times}
\expandafter\ifx\csname T@LGR\endcsname\relax
Expand Down
8 changes: 3 additions & 5 deletions sphinx/builders/latex/transforms.py
Expand Up @@ -8,18 +8,16 @@
:license: BSD, see LICENSE for details.
"""

from typing import Any, Dict, List, Set, Tuple
from typing import cast
from typing import Any, Dict, List, Set, Tuple, cast

from docutils import nodes
from docutils.nodes import Element, Node
from docutils.transforms.references import Substitutions

from sphinx import addnodes
from sphinx.application import Sphinx
from sphinx.builders.latex.nodes import (
captioned_literal_block, footnotemark, footnotetext, math_reference, thebibliography
)
from sphinx.builders.latex.nodes import (captioned_literal_block, footnotemark, footnotetext,
math_reference, thebibliography)
from sphinx.domains.citation import CitationDomain
from sphinx.transforms import SphinxTransform
from sphinx.transforms.post_transforms import SphinxPostTransform
Expand Down
7 changes: 2 additions & 5 deletions sphinx/builders/linkcheck.py
Expand Up @@ -25,14 +25,11 @@
from sphinx.application import Sphinx
from sphinx.builders import Builder
from sphinx.locale import __
from sphinx.util import encode_uri, requests, logging
from sphinx.util.console import ( # type: ignore
purple, red, darkgreen, darkgray, turquoise
)
from sphinx.util import encode_uri, logging, requests
from sphinx.util.console import darkgray, darkgreen, purple, red, turquoise # type: ignore
from sphinx.util.nodes import get_node_line
from sphinx.util.requests import is_ssl_error


logger = logging.getLogger(__name__)

uri_re = re.compile('([a-z]+:)?//') # matches to foo:// and // (a protocol relative URL)
Expand Down

0 comments on commit 2a26761

Please sign in to comment.