Skip to content

Commit df3050d

Browse files
authored
Add test for final decorator independent of typing-extensions (#723)
1 parent 5daf387 commit df3050d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

jsonargparse_tests/test_optionals.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from __future__ import annotations
22

3+
import sys
4+
35
import pytest
46

57
from jsonargparse import set_parsing_settings
68
from jsonargparse._optionals import (
79
_get_config_read_mode,
810
docstring_parser_support,
11+
final,
912
fsspec_support,
1013
get_docstring_parse_options,
1114
import_docstring_parser,
@@ -19,6 +22,7 @@
1922
ruyaml_support,
2023
url_support,
2124
)
25+
from jsonargparse.typing import is_final_class
2226
from jsonargparse_tests.conftest import (
2327
skip_if_docstring_parser_unavailable,
2428
skip_if_fsspec_unavailable,
@@ -176,3 +180,17 @@ def test_config_read_mode_fsspec_support_false():
176180
assert "fr" == _get_config_read_mode()
177181
set_parsing_settings(config_read_mode_fsspec_enabled=False)
178182
assert "fr" == _get_config_read_mode()
183+
184+
185+
# final decorator tests
186+
187+
188+
@final
189+
class FinalClass:
190+
pass
191+
192+
193+
@pytest.mark.skipif(sys.version_info < (3, 11), reason="final decorator __final__ introduced in python 3.11")
194+
def test_final_decorator():
195+
assert is_final_class(FinalClass) is True
196+
assert is_final_class(test_final_decorator) is False

0 commit comments

Comments
 (0)