diff options
Diffstat (limited to 'tests/functional/c/comparison_with_callable_typing_constants.py')
-rw-r--r-- | tests/functional/c/comparison_with_callable_typing_constants.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/functional/c/comparison_with_callable_typing_constants.py b/tests/functional/c/comparison_with_callable_typing_constants.py new file mode 100644 index 000000000..70aa9763f --- /dev/null +++ b/tests/functional/c/comparison_with_callable_typing_constants.py @@ -0,0 +1,18 @@ +"""Typing constants are actually implemented as functions, but they +raise when called, so Pylint uses that to avoid false positives for +comparison-with-callable. +""" +from typing import Any, Optional + + +def check_any(type_) -> bool: + """See https://github.com/PyCQA/pylint/issues/5557""" + return type_ == Any + + +def check_optional(type_) -> bool: + """ + Unlike Any, Optional does not raise in its body. + It raises via its decorator: typing._SpecialForm.__call__() + """ + return type_ == Optional |