Skip to content

Commit eff6eaa

Browse files
committed
jedi: Add ustruct, json modules.
1 parent f7984a4 commit eff6eaa

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

jedi/src/pybricks_jedi/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
"pybricks.tools",
2222
"uerrno",
2323
"uio",
24+
"ujson",
2425
"umath",
2526
"urandom",
2627
"uselect",
28+
"ustruct",
2729
"usys",
2830
}
2931

jedi/tests/test_complete_import.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ def test_from():
1818
"pybricks",
1919
"uerrno",
2020
"uio",
21+
"ujson",
2122
"umath",
2223
"urandom",
2324
"uselect",
25+
"ustruct",
2426
"usys",
2527
]
2628

@@ -186,6 +188,19 @@ def test_from_uio_import():
186188
]
187189

188190

191+
def test_from_ujson_import():
192+
code = "from ujson import "
193+
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
194+
assert [c["insertText"] for c in completions] == [
195+
"decode", # FIXME: Shouldn't be here
196+
"dump",
197+
"dumps",
198+
"encode", # FIXME: Shouldn't be here
199+
"load",
200+
"loads",
201+
]
202+
203+
189204
def test_from_umath_import():
190205
code = "from umath import "
191206
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
@@ -247,6 +262,18 @@ def test_from_uselect_import():
247262
]
248263

249264

265+
def test_from_ustruct_import():
266+
code = "from ustruct import "
267+
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
268+
assert [c["insertText"] for c in completions] == [
269+
"calcsize",
270+
"pack",
271+
"pack_into",
272+
"unpack",
273+
"unpack_from",
274+
]
275+
276+
250277
def test_from_usys_import():
251278
code = "from usys import "
252279
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ packages = [
1818
{ include = "micropython", from = "src" },
1919
{ include = "uerrno", from = "src" },
2020
{ include = "uio", from = "src" },
21+
{ include = "ujson", from = "src" },
2122
{ include = "umath", from = "src" },
2223
{ include = "urandom", from = "src" },
2324
{ include = "uselect", from = "src" },
25+
{ include = "ustruct", from = "src" },
2426
{ include = "usys", from = "src" },
2527
]
2628

src/ujson/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
from typing import IO, Any, Tuple
1313

14-
import json
15-
16-
json.dump
17-
1814

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

0 commit comments

Comments
 (0)