Skip to content

Commit

Permalink
jedi: Add ustruct, json modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurensvalk committed Dec 2, 2022
1 parent f7984a4 commit fb7a930
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 2 additions & 0 deletions jedi/src/pybricks_jedi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"pybricks.tools",
"uerrno",
"uio",
"ujson",
"umath",
"urandom",
"uselect",
"ustruct",
"usys",
}

Expand Down
25 changes: 25 additions & 0 deletions jedi/tests/test_complete_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ def test_from():
"pybricks",
"uerrno",
"uio",
"ujson",
"umath",
"urandom",
"uselect",
"ustruct",
"usys",
]

Expand Down Expand Up @@ -186,6 +188,17 @@ def test_from_uio_import():
]


def test_from_ujson_import():
code = "from ujson import "
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
assert [c["insertText"] for c in completions] == [
"dump",
"dumps",
"load",
"loads",
]


def test_from_umath_import():
code = "from umath import "
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
Expand Down Expand Up @@ -247,6 +260,18 @@ def test_from_uselect_import():
]


def test_from_ustruct_import():
code = "from ustruct import "
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
assert [c["insertText"] for c in completions] == [
"calcsize",
"pack",
"pack_into",
"unpack",
"unpack_from",
]


def test_from_usys_import():
code = "from usys import "
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ packages = [
{ include = "micropython", from = "src" },
{ include = "uerrno", from = "src" },
{ include = "uio", from = "src" },
{ include = "ujson", from = "src" },
{ include = "umath", from = "src" },
{ include = "urandom", from = "src" },
{ include = "uselect", from = "src" },
{ include = "ustruct", from = "src" },
{ include = "usys", from = "src" },
]

Expand Down
4 changes: 0 additions & 4 deletions src/ujson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

from typing import IO, Any, Tuple

import json

json.dump


def dump(object: Any, stream: IO, separators: Tuple[str, str] = (", ", ": ")):
"""
Expand Down

0 comments on commit fb7a930

Please sign in to comment.