From 8014c022b680f071bf0ee9f543d31f35c3b510d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 21 Sep 2021 18:51:07 +0200 Subject: [PATCH] fix: Support future annotations --- src/pytkdocs/loader.py | 2 ++ tests/fixtures/final.py | 10 ++++++++++ tests/test_loader.py | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 tests/fixtures/final.py diff --git a/src/pytkdocs/loader.py b/src/pytkdocs/loader.py index a8cc8c5..658cc34 100644 --- a/src/pytkdocs/loader.py +++ b/src/pytkdocs/loader.py @@ -5,6 +5,8 @@ iterating over their members, etc. """ +from __future__ import annotations + import importlib import inspect import pkgutil diff --git a/tests/fixtures/final.py b/tests/fixtures/final.py new file mode 100644 index 0000000..33a788f --- /dev/null +++ b/tests/fixtures/final.py @@ -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) diff --git a/tests/test_loader.py b/tests/test_loader.py index 9c8d98a..bb15fe7 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -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")