Skip to content

Commit

Permalink
Import from collections.abc
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jul 22, 2024
1 parent 1306426 commit 4651d7a
Show file tree
Hide file tree
Showing 32 changed files with 71 additions and 63 deletions.
4 changes: 2 additions & 2 deletions sphinx/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import pickle
import sys
from collections import deque
from collections.abc import Collection, Sequence # NoQA: TCH003
from collections.abc import Callable, Collection, Sequence # NoQA: TCH003
from io import StringIO
from os import path
from typing import IO, TYPE_CHECKING, Any, Callable, Literal
from typing import IO, TYPE_CHECKING, Any, Literal

from docutils.nodes import TextElement # NoQA: TCH002
from docutils.parsers.rst import Directive, roles
Expand Down
4 changes: 2 additions & 2 deletions sphinx/builders/linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
from sphinx.util.nodes import get_node_line

if TYPE_CHECKING:
from collections.abc import Iterator
from typing import Any, Callable
from collections.abc import Callable, Iterator
from typing import Any

from requests import Response

Expand Down
4 changes: 2 additions & 2 deletions sphinx/cmd/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys
import time
from os import path
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

# try to import readline, unix specific enhancement
try:
Expand Down Expand Up @@ -36,7 +36,7 @@
from sphinx.util.template import SphinxRenderer

if TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Callable, Sequence

EXTENSIONS = {
'autodoc': __('automatically insert docstrings from modules'),
Expand Down
3 changes: 2 additions & 1 deletion sphinx/domains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import copy
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Callable, NamedTuple, Optional, cast
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, NamedTuple, Optional, cast

from docutils.nodes import Element, Node, system_message

Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/c/_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from sphinx.domains.c._ast import (
ASTAlignofExpr,
Expand Down Expand Up @@ -80,7 +80,7 @@
)

if TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Callable, Sequence


class DefinitionParser(BaseParser):
Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/cpp/_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import re
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from sphinx.domains.cpp._ast import (
ASTAlignofExpr,
Expand Down Expand Up @@ -127,7 +127,7 @@
)

if TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Callable, Sequence

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/cpp/_symbol.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable, NoReturn
from typing import TYPE_CHECKING, Any, NoReturn

from sphinx.domains.cpp._ast import (
ASTDeclaration,
Expand All @@ -17,7 +17,7 @@
from sphinx.util import logging

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import Callable, Iterator

from sphinx.environment import BuildEnvironment

Expand Down
4 changes: 2 additions & 2 deletions sphinx/domains/std/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import re
from copy import copy
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Final, cast
from typing import TYPE_CHECKING, Any, ClassVar, Final, cast

from docutils import nodes
from docutils.nodes import Element, Node, system_message
Expand All @@ -23,7 +23,7 @@
from sphinx.util.parsing import nested_parse_to_nodes

if TYPE_CHECKING:
from collections.abc import Iterable, Iterator
from collections.abc import Callable, Iterable, Iterator

from sphinx.application import Sphinx
from sphinx.builders import Builder
Expand Down
4 changes: 2 additions & 2 deletions sphinx/environment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from collections import defaultdict
from copy import copy
from os import path
from typing import TYPE_CHECKING, Any, Callable, NoReturn
from typing import TYPE_CHECKING, Any, NoReturn

from sphinx import addnodes
from sphinx.environment.adapters import toctree as toctree_adapters
Expand All @@ -23,7 +23,7 @@
from sphinx.util.osutil import canon_path, os_path

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import Callable, Iterator
from pathlib import Path

from docutils import nodes
Expand Down
4 changes: 1 addition & 3 deletions sphinx/environment/adapters/indexentries.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
from sphinx.util.index_entries import _split_into

if TYPE_CHECKING:
from typing import Literal, Optional, Union

from typing_extensions import TypeAlias
from typing import Literal, Optional, TypeAlias, Union

from sphinx.builders import Builder
from sphinx.environment import BuildEnvironment
Expand Down
4 changes: 3 additions & 1 deletion sphinx/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
import contextlib
from collections import defaultdict
from operator import attrgetter
from typing import TYPE_CHECKING, Any, Callable, NamedTuple
from typing import TYPE_CHECKING, Any, NamedTuple

from sphinx.errors import ExtensionError, SphinxError
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.inspect import safe_getattr

if TYPE_CHECKING:
from collections.abc import Callable

from sphinx.application import Sphinx


Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import operator
import re
from inspect import Parameter, Signature
from typing import TYPE_CHECKING, Any, Callable, ClassVar, TypeVar
from typing import TYPE_CHECKING, Any, ClassVar, TypeVar

from docutils.statemachine import StringList

Expand Down Expand Up @@ -39,7 +39,7 @@
)

if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
from collections.abc import Callable, Iterator, Sequence
from types import ModuleType

from sphinx.application import Sphinx
Expand Down
3 changes: 2 additions & 1 deletion sphinx/ext/autodoc/directive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable
from collections.abc import Callable
from typing import TYPE_CHECKING, Any

from docutils import nodes
from docutils.statemachine import StringList
Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import time
from io import StringIO
from os import path
from typing import TYPE_CHECKING, Any, Callable, ClassVar
from typing import TYPE_CHECKING, Any, ClassVar

from docutils import nodes
from docutils.parsers.rst import directives
Expand All @@ -27,7 +27,7 @@
from sphinx.util.osutil import relpath

if TYPE_CHECKING:
from collections.abc import Iterable, Sequence
from collections.abc import Callable, Iterable, Sequence

from docutils.nodes import Element, Node, TextElement

Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/napoleon/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import re
from functools import partial
from itertools import starmap
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from sphinx.locale import _, __
from sphinx.util import logging
from sphinx.util.typing import get_type_hints, stringify_annotation

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import Callable, Iterator

from sphinx.application import Sphinx
from sphinx.config import Config as SphinxConfig
Expand Down
4 changes: 2 additions & 2 deletions sphinx/jinja2glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from os import path
from pprint import pformat
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from jinja2 import BaseLoader, FileSystemLoader, TemplateNotFound
from jinja2.sandbox import SandboxedEnvironment
Expand All @@ -15,7 +15,7 @@
from sphinx.util.osutil import mtimes_of_files

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import Callable, Iterator

from jinja2.environment import Environment

Expand Down
4 changes: 2 additions & 2 deletions sphinx/locale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Iterable
from typing import Any, Callable
from collections.abc import Callable, Iterable
from typing import Any


class _TranslationProxy:
Expand Down
4 changes: 2 additions & 2 deletions sphinx/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from importlib import import_module
from importlib.metadata import entry_points
from types import MethodType
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from sphinx.domains import Domain, Index, ObjType
from sphinx.domains.std import GenericObject, Target
Expand All @@ -20,7 +20,7 @@
from sphinx.util.logging import prefixed_warnings

if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
from collections.abc import Callable, Iterator, Sequence

from docutils import nodes
from docutils.core import Publisher
Expand Down
3 changes: 2 additions & 1 deletion sphinx/testing/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import shutil
import sys
import warnings
from typing import IO, TYPE_CHECKING, Any, Callable
from typing import IO, TYPE_CHECKING, Any

from sphinx.deprecation import RemovedInSphinx90Warning

if TYPE_CHECKING:
import builtins
from collections.abc import Callable

warnings.warn("'sphinx.testing.path' is deprecated. "
"Use 'os.path' or 'pathlib' instead.",
Expand Down
4 changes: 2 additions & 2 deletions sphinx/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

if TYPE_CHECKING:
from collections.abc import Iterator
from typing import Literal
from typing import Literal, TypeAlias

from docutils.nodes import Node, Text
from typing_extensions import TypeAlias, TypeIs
from typing_extensions import TypeIs

from sphinx.application import Sphinx
from sphinx.config import Config
Expand Down
3 changes: 2 additions & 1 deletion sphinx/util/cfamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from __future__ import annotations

import re
from collections.abc import Callable
from copy import deepcopy
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from docutils import nodes

Expand Down
4 changes: 2 additions & 2 deletions sphinx/util/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from sphinx.util.console import bold, color_terminal

if False:
from collections.abc import Iterable, Iterator
from collections.abc import Callable, Iterable, Iterator
from types import TracebackType
from typing import Any, Callable, TypeVar
from typing import Any, TypeVar

from typing_extensions import ParamSpec

Expand Down
11 changes: 8 additions & 3 deletions sphinx/util/docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import os
import re
from collections.abc import Sequence # NoQA: TCH003
from collections.abc import (
Sequence, # NoQA: TCH003
)
from contextlib import contextmanager
from copy import copy
from os import path
from typing import IO, TYPE_CHECKING, Any, Callable, cast
from typing import IO, TYPE_CHECKING, Any, cast

import docutils
from docutils import nodes
Expand All @@ -27,7 +29,10 @@
report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) ')

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import (
Callable, # NoQA: TCH003
Iterator,
)
from types import ModuleType

from docutils.frontend import Values
Expand Down
4 changes: 3 additions & 1 deletion sphinx/util/fileutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

import os
import posixpath
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from docutils.utils import relative_path

from sphinx.util import logging
from sphinx.util.osutil import copyfile, ensuredir

if TYPE_CHECKING:
from collections.abc import Callable

from sphinx.util.template import BaseRenderer
from sphinx.util.typing import PathMatcher

Expand Down
4 changes: 2 additions & 2 deletions sphinx/util/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from collections.abc import Callable, Sequence
from inspect import _ParameterKind
from types import MethodType, ModuleType
from typing import Final, Protocol, Union
from typing import Final, Protocol, TypeAlias, Union

from typing_extensions import TypeAlias, TypeIs
from typing_extensions import TypeIs

class _SupportsGet(Protocol):
def __get__(self, __instance: Any, __owner: type | None = ...) -> Any: ... # NoQA: E704
Expand Down
Loading

0 comments on commit 4651d7a

Please sign in to comment.