Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fully_qualified should be typehints_fully_qualified #204

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.15.1

- Fix `fully_qualified` should be `typehints_fully_qualified`

## 1.15.0

- Resolve type guard imports before evaluating annotations for objects
Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def format_annotation(annotation: Any, config: Config) -> str:
module = "typing"

full_name = f"{module}.{class_name}" if module != "builtins" else class_name
fully_qualified: bool = getattr(config, "fully_qualified", False)
fully_qualified: bool = getattr(config, "typehints_fully_qualified", False)
prefix = "" if fully_qualified or full_name == class_name else "~"
role = "data" if class_name in _PYDATA_ANNOTATIONS else "class"
args_format = "\\[{}]"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ def test_format_annotation(inv: Inventory, annotation: Any, expected_result: str
# Test with the "fully_qualified" flag turned on
if "typing" in expected_result_not_simplified:
expected_result_not_simplified = expected_result_not_simplified.replace("~typing", "typing")
conf = create_autospec(Config, fully_qualified=True, simplify_optional_unions=False)
conf = create_autospec(Config, typehints_fully_qualified=True, simplify_optional_unions=False)
assert format_annotation(annotation, conf) == expected_result_not_simplified

# Test with the "fully_qualified" flag turned on
if "typing" in expected_result or __name__ in expected_result:
expected_result = expected_result.replace("~typing", "typing")
expected_result = expected_result.replace("~" + __name__, __name__)
conf = create_autospec(Config, fully_qualified=True)
conf = create_autospec(Config, typehints_fully_qualified=True)
assert format_annotation(annotation, conf) == expected_result

# Test for the correct role (class vs data) using the official Sphinx inventory
Expand Down