Skip to content

Use correct role for exception links #17

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

Merged
merged 2 commits into from
Sep 6, 2020
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
dist: xenial
language: python
cache: pip
branches:
only:
- master # use PR builder only for other branches
python:
- '3.6'
- '3.7'
Expand Down
2 changes: 1 addition & 1 deletion scanpydoc/elegant_typehints/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _format_full(annotation: Type[Any], fully_qualified: bool = False):
if inspect.isclass(annotation) or inspect.isclass(origin):
full_name = f"{annotation.__module__}.{annotation.__qualname__}"
override = elegant_typehints.qualname_overrides.get(full_name)
role = "exception" if issubclass(annotation_cls, BaseException) else "class"
role = "exc" if issubclass(annotation_cls, BaseException) else "class"
if override is not None:
return f":py:{role}:`{tilde}{override}`"

Expand Down
2 changes: 1 addition & 1 deletion tests/test_elegant_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_qualname_overrides_class(app):

def test_qualname_overrides_exception(app):
assert TestExc.__module__ == "_testmod"
assert _format_terse(TestExc) == ":py:exception:`~test.Excep`"
assert _format_terse(TestExc) == ":py:exc:`~test.Excep`"


def test_qualname_overrides_recursive(app):
Expand Down