Skip to content

Commit bb2fa3a

Browse files
committed
package: switch to @pybricks/python-program-analysis
The package we were using was only for Python 3.4 and didn't include async/await which broke imports in any script that used async/await. Fixes: pybricks/support#873
1 parent a77acc1 commit bb2fa3a

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
### Changed
1111
- Changed app display from "fullscreen" to "standalone" ([support#867]).
1212

13+
### Fixed
14+
- Fixed imports in scripts that use `async` or `await` keywords ([support#873]).
15+
1316
[support#867]: https://github.com/pybricks/support/issues/867
17+
[support#873]: https://github.com/pybricks/support/issues/873
1418

1519
## [2.0.1] - 2022-12-21
1620

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@pybricks/jedi": "1.6.0",
2020
"@pybricks/mpy-cross-v5": "^2.0.0",
2121
"@pybricks/mpy-cross-v6": "^2.0.0",
22-
"@qoretechnologies/python-parser": "^0.4.10",
22+
"@pybricks/python-program-analysis": "^1.0.1",
2323
"@reduxjs/toolkit": "^1.9.1",
2424
"@shopify/react-i18n": "^7.5.1",
2525
"@svgr/webpack": "^6.5.1",

src/pybricksMicropython/lib.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,18 @@ from q import q
131131
]),
132132
);
133133
});
134+
135+
test('https://github.com/pybricks/support/issues/873 regression', () => {
136+
const script = `
137+
from my_module import data
138+
139+
async def hello():
140+
print("hello")
141+
142+
print(data)
143+
`;
144+
145+
const modules = findImportedModules(script);
146+
147+
expect(modules).toEqual(new Set(['my_module']));
148+
});

src/pybricksMicropython/lib.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
// Copyright (c) 2022 The Pybricks Authors
33

4-
import { parse, walk } from '@qoretechnologies/python-parser';
4+
import { parse, walk } from '@pybricks/python-program-analysis';
55
import type { FileContents, FileStorageDb } from '../fileStorage';
66

77
/** The Python file extension ('.py') */
@@ -99,7 +99,7 @@ export function findImportedModules(py: string): ReadonlySet<string> {
9999
});
100100
} catch (err) {
101101
// istanbul ignore if
102-
if (process.env.NODE_ENV !== 'test') {
102+
if (process.env.NODE_ENV === 'test') {
103103
console.error(err);
104104
}
105105

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,7 @@ __metadata:
24182418
"@pybricks/jedi": 1.6.0
24192419
"@pybricks/mpy-cross-v5": ^2.0.0
24202420
"@pybricks/mpy-cross-v6": ^2.0.0
2421-
"@qoretechnologies/python-parser": ^0.4.10
2421+
"@pybricks/python-program-analysis": ^1.0.1
24222422
"@reduxjs/toolkit": ^1.9.1
24232423
"@shopify/react-i18n": ^7.5.1
24242424
"@svgr/webpack": ^6.5.1
@@ -2541,12 +2541,12 @@ __metadata:
25412541
languageName: unknown
25422542
linkType: soft
25432543

2544-
"@qoretechnologies/python-parser@npm:^0.4.10":
2545-
version: 0.4.10
2546-
resolution: "@qoretechnologies/python-parser@npm:0.4.10"
2544+
"@pybricks/python-program-analysis@npm:^1.0.1":
2545+
version: 1.0.1
2546+
resolution: "@pybricks/python-program-analysis@npm:1.0.1"
25472547
dependencies:
25482548
lodash: ^4.17.15
2549-
checksum: ab0d91719a8301b64f9c7fb1a7711721d52d78325abbf0c7c75940a48fd4a3d2b07456c95f8507af19faa333bf87116dd62f18e6c8e76486a57673e3224ac3ee
2549+
checksum: f34171e8b315b4f81c7f0768ce644c22965e3f9fc2c2514fa6256601e05f2e4c9df0518b2a591ac8455f4d54f48929cd8c741f8751dd6d6e792a2520339ca7bb
25502550
languageName: node
25512551
linkType: hard
25522552

0 commit comments

Comments
 (0)