From c5e32322417ac7629b934772c7b3d7146104b0f3 Mon Sep 17 00:00:00 2001 From: Mark Koch Date: Wed, 31 Jul 2024 17:24:38 +0100 Subject: [PATCH] Special case parsing of Callable --- tests/error/misc_errors/callable_no_args.err | 6 ++++++ tests/error/misc_errors/callable_no_args.py | 13 +++++++++++++ tests/error/misc_errors/callable_not_list1.err | 6 ++++++ tests/error/misc_errors/callable_not_list1.py | 13 +++++++++++++ tests/error/misc_errors/callable_not_list2.err | 6 ++++++ tests/error/misc_errors/callable_not_list2.py | 13 +++++++++++++ 6 files changed, 57 insertions(+) create mode 100644 tests/error/misc_errors/callable_no_args.err create mode 100644 tests/error/misc_errors/callable_no_args.py create mode 100644 tests/error/misc_errors/callable_not_list1.err create mode 100644 tests/error/misc_errors/callable_not_list1.py create mode 100644 tests/error/misc_errors/callable_not_list2.err create mode 100644 tests/error/misc_errors/callable_not_list2.py diff --git a/tests/error/misc_errors/callable_no_args.err b/tests/error/misc_errors/callable_no_args.err new file mode 100644 index 00000000..b4391cb4 --- /dev/null +++ b/tests/error/misc_errors/callable_no_args.err @@ -0,0 +1,6 @@ +Guppy compilation failed. Error in file $FILE:10 + +8: @guppy.declare(module) +9: def foo(f: Callable) -> None: ... + ^^^^^^^^ +GuppyError: Function types should be specified via `Callable[[], ]` diff --git a/tests/error/misc_errors/callable_no_args.py b/tests/error/misc_errors/callable_no_args.py new file mode 100644 index 00000000..6401cf95 --- /dev/null +++ b/tests/error/misc_errors/callable_no_args.py @@ -0,0 +1,13 @@ +from typing import Callable + +from guppylang.decorator import guppy +from guppylang.module import GuppyModule + + +module = GuppyModule("test") + +@guppy.declare(module) +def foo(f: "Callable[None]") -> None: ... + + +module.compile() diff --git a/tests/error/misc_errors/callable_not_list1.err b/tests/error/misc_errors/callable_not_list1.err new file mode 100644 index 00000000..fb09294a --- /dev/null +++ b/tests/error/misc_errors/callable_not_list1.err @@ -0,0 +1,6 @@ +Guppy compilation failed. Error in file $FILE:10 + +8: @guppy.declare(module) +9: def foo(f: "Callable[int, float, bool]") -> None: ... + ^^^^^^^^^^^^^^^^^^^^^^^^^^ +GuppyError: Function types should be specified via `Callable[[], ]` diff --git a/tests/error/misc_errors/callable_not_list1.py b/tests/error/misc_errors/callable_not_list1.py new file mode 100644 index 00000000..1aebc43a --- /dev/null +++ b/tests/error/misc_errors/callable_not_list1.py @@ -0,0 +1,13 @@ +from typing import Callable + +from guppylang.decorator import guppy +from guppylang.module import GuppyModule + + +module = GuppyModule("test") + +@guppy.declare(module) +def foo(f: "Callable[int, float, bool]") -> None: ... + + +module.compile() diff --git a/tests/error/misc_errors/callable_not_list2.err b/tests/error/misc_errors/callable_not_list2.err new file mode 100644 index 00000000..44246aad --- /dev/null +++ b/tests/error/misc_errors/callable_not_list2.err @@ -0,0 +1,6 @@ +Guppy compilation failed. Error in file $FILE:10 + +8: @guppy.declare(module) +9: def foo(f: "Callable[None]") -> None: ... + ^^^^^^^^^^^^^^ +GuppyError: Function types should be specified via `Callable[[], ]` diff --git a/tests/error/misc_errors/callable_not_list2.py b/tests/error/misc_errors/callable_not_list2.py new file mode 100644 index 00000000..1aebc43a --- /dev/null +++ b/tests/error/misc_errors/callable_not_list2.py @@ -0,0 +1,13 @@ +from typing import Callable + +from guppylang.decorator import guppy +from guppylang.module import GuppyModule + + +module = GuppyModule("test") + +@guppy.declare(module) +def foo(f: "Callable[int, float, bool]") -> None: ... + + +module.compile()