Skip to content

fix: Support future annotations #113

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions src/pytkdocs/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
iterating over their members, etc.
"""

from __future__ import annotations

import importlib
import inspect
import pkgutil
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/final.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# from __future__ import annotations

from typing import Final, get_type_hints

name: Final[str] = "final"

class Class:
value: Final = 3000

# get_type_hints(Class)
5 changes: 5 additions & 0 deletions tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,8 @@ def test_load_decorated_function():
assert child.category == "function"
assert child.parent is child.root
assert child.parent.name == "decorated_function"

def test_load_final_annotations():
"""Load things annotated as final."""
loader = Loader(new_path_syntax=True)
obj = loader.get_object_documentation("tests.fixtures.final")