Skip to content

Commit

Permalink
Special case parsing of Callable
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-koch committed Jul 31, 2024
1 parent 77a4dc8 commit c5e3232
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/error/misc_errors/callable_no_args.err
Original file line number Diff line number Diff line change
@@ -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[[<arguments>], <return types>]`
13 changes: 13 additions & 0 deletions tests/error/misc_errors/callable_no_args.py
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 6 additions & 0 deletions tests/error/misc_errors/callable_not_list1.err
Original file line number Diff line number Diff line change
@@ -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[[<arguments>], <return types>]`
13 changes: 13 additions & 0 deletions tests/error/misc_errors/callable_not_list1.py
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 6 additions & 0 deletions tests/error/misc_errors/callable_not_list2.err
Original file line number Diff line number Diff line change
@@ -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[[<arguments>], <return types>]`
13 changes: 13 additions & 0 deletions tests/error/misc_errors/callable_not_list2.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit c5e3232

Please sign in to comment.