Skip to content

Commit

Permalink
Start implementing pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Apr 28, 2024
1 parent 7c60c77 commit 42958a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion coconut/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ from coconut.command.command import Command

class CoconutException(Exception):
"""Coconut Exception."""
...

def syntax_err(self) -> SyntaxError:
...

#-----------------------------------------------------------------------------------------------------------------------
# COMMAND:
Expand Down
7 changes: 7 additions & 0 deletions coconut/command/resources/pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extraPaths": [
"C://Users/evanj/.coconut_stubs"
],
"pythonVersion": "3.11",
"reportPossiblyUnboundVariable": false
}
6 changes: 3 additions & 3 deletions coconut/tests/src/extras.coco
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from coconut.convenience import (
)


def assert_raises(c, Exc, not_Exc=None, err_has=None):
def assert_raises(c, Exc, not_Exc=None, err_has=None) -> None:
"""Test whether callable c raises an exception of type Exc."""
if not_Exc is None and Exc is CoconutSyntaxError:
not_Exc = CoconutParseError
Expand Down Expand Up @@ -533,7 +533,7 @@ class F:

def test_kernel() -> bool:
# hide imports so as to not enable incremental parsing until we want to
if PY35:
if PY35 or TYPE_CHECKING:
import asyncio
from coconut.icoconut import CoconutKernel # type: ignore
from jupyter_client.session import Session
Expand All @@ -555,7 +555,7 @@ def test_kernel() -> bool:
k = CoconutKernel()
fake_session = FakeSession()
assert k.shell is not None
k.shell.displayhook.session = fake_session
k.shell.displayhook.session = fake_session # type: ignore

exec_result = k.do_execute("derp = pow$(?, 2)", False, True, {"two": "(+)(1, 1)"}, True) |> unwrap_future$(loop)
assert exec_result["status"] == "ok", exec_result
Expand Down

0 comments on commit 42958a6

Please sign in to comment.