Skip to content

Commit 27555dd

Browse files
authored
Remove set_type_checking flag (#202)
1 parent e2e780d commit 27555dd

File tree

3 files changed

+1
-10
lines changed

3 files changed

+1
-10
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## dev
44

55
- Resolve type guard imports before evaluating annotations for objects
6+
- Remove `set_type_checking_flag` flag as this is now done by default
67
- Fix crash when the `inspect` module returns an invalid python syntax source
78
- Made formatting function configurable using the option `typehints_formatter`
89

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ extensions = ["sphinx.ext.autodoc", "sphinx_autodoc_typehints"]
5353

5454
The following configuration options are accepted:
5555

56-
- `set_type_checking_flag` (default: `False`): if `True`, set `typing.TYPE_CHECKING` to `True` to enable \"expensive\"
57-
typing imports
5856
- `typehints_fully_qualified` (default: `False`): if `True`, class names are always fully qualified (e.g.
5957
`module.for.Class`). If `False`, just the class name displays (e.g. `Class`)
6058
- `always_document_param_types` (default: `False`): If `False`, do not add type info for undocumented parameters. If

src/sphinx_autodoc_typehints/__init__.py

-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55
import sys
66
import textwrap
7-
import typing
87
from ast import FunctionDef, Module, stmt
98
from typing import Any, AnyStr, Callable, NewType, TypeVar, get_type_hints
109

@@ -499,11 +498,6 @@ def process_docstring(
499498
lines.insert(insert_index, f":rtype: {formatted_annotation}")
500499

501500

502-
def builder_ready(app: Sphinx) -> None:
503-
if app.config.set_type_checking_flag:
504-
typing.TYPE_CHECKING = True
505-
506-
507501
def validate_config(app: Sphinx, env: BuildEnvironment, docnames: list[str]) -> None: # noqa: U100
508502
valid = {None, "comma", "braces", "braces-after"}
509503
if app.config.typehints_defaults not in valid | {False}:
@@ -515,14 +509,12 @@ def validate_config(app: Sphinx, env: BuildEnvironment, docnames: list[str]) ->
515509

516510

517511
def setup(app: Sphinx) -> dict[str, bool]:
518-
app.add_config_value("set_type_checking_flag", False, "html")
519512
app.add_config_value("always_document_param_types", False, "html")
520513
app.add_config_value("typehints_fully_qualified", False, "env")
521514
app.add_config_value("typehints_document_rtype", True, "env")
522515
app.add_config_value("typehints_defaults", None, "env")
523516
app.add_config_value("simplify_optional_unions", True, "env")
524517
app.add_config_value("typehints_formatter", None, "env")
525-
app.connect("builder-inited", builder_ready)
526518
app.connect("env-before-read-docs", validate_config) # config may be changed after “config-inited” event
527519
app.connect("autodoc-process-signature", process_signature)
528520
app.connect("autodoc-process-docstring", process_docstring)

0 commit comments

Comments
 (0)