Skip to content

Commit 8014c02

Browse files
committed
fix: Support future annotations
1 parent 8927e2f commit 8014c02

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/pytkdocs/loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
iterating over their members, etc.
66
"""
77

8+
from __future__ import annotations
9+
810
import importlib
911
import inspect
1012
import pkgutil

tests/fixtures/final.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# from __future__ import annotations
2+
3+
from typing import Final, get_type_hints
4+
5+
name: Final[str] = "final"
6+
7+
class Class:
8+
value: Final = 3000
9+
10+
# get_type_hints(Class)

tests/test_loader.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,8 @@ def test_load_decorated_function():
536536
assert child.category == "function"
537537
assert child.parent is child.root
538538
assert child.parent.name == "decorated_function"
539+
540+
def test_load_final_annotations():
541+
"""Load things annotated as final."""
542+
loader = Loader(new_path_syntax=True)
543+
obj = loader.get_object_documentation("tests.fixtures.final")

0 commit comments

Comments
 (0)