Skip to content

Commit 87b70e5

Browse files
authored
feat: python code validation (#939)
Add python code validation on deploy #### Migration notes --- - [x] The change comes with new or modified tests - [ ] Hard-to-understand functions have explanatory comments - [ ] End-user documentation is updated to reflect the change
1 parent 6b68642 commit 87b70e5

File tree

17 files changed

+433
-75
lines changed

17 files changed

+433
-75
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ repos:
7171
args:
7272
- --maxkb=768
7373
- id: check-ast
74+
exclude: tests/runtimes/python/py_fail/.*\.py
7475
- id: check-json
7576
exclude: .vscode/.*\.json
7677
- id: check-toml
@@ -137,8 +138,12 @@ repos:
137138
rev: "v0.5.1"
138139
hooks:
139140
- id: ruff
141+
exclude: tests/runtimes/python/py_fail/.*\.py
140142
- id: ruff-format
141-
exclude: "tests/metagen/typegraphs/sample/py/client.py"
143+
exclude: (?x)(
144+
tests/metagen/typegraphs/sample/py/client.py"|
145+
tests/runtimes/python/py_fail/.*\.py
146+
)
142147
- repo: https://github.com/commitizen-tools/commitizen
143148
rev: v3.27.0
144149
hooks:

Cargo.lock

Lines changed: 184 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ members = [
1414
"src/metagen-client-rs",
1515
"tests/metagen/typegraphs/sample/rs",
1616
"tests/metagen/typegraphs/sample/rs_upload",
17-
]
17+
]
1818

1919
exclude = [
2020
"tests/runtimes/wasm_reflected/rust",
@@ -72,19 +72,19 @@ sha2 = "0.10.8"
7272
seahash = "4.1.0"
7373

7474
# patterns
75-
anyhow = "1.0.89" # FIXME: replace anyhow with eyre
75+
anyhow = "1.0.89" # FIXME: replace anyhow with eyre
7676
color-eyre = "0.6.3"
77-
eyre = "0.6.12" # NOTE: keep in sync with verison used by color-eyre
77+
eyre = "0.6.12" # NOTE: keep in sync with verison used by color-eyre
7878
thiserror = "1.0.64"
7979
indoc = "2.0.5"
8080
unindent = "0.2.3"
8181
itertools = "0.13.0"
82-
lazy_static = "1.5.0" # FIXME: replace with Lazy Cell
82+
lazy_static = "1.5.0" # FIXME: replace with Lazy Cell
8383
crossbeam-channel = "0.5.13"
8484
enum_dispatch = "0.3.13"
8585
tap = "1.0.1"
8686
derive_more = { version = "1", features = ["from"] }
87-
cached = "0.53.1" # FIXME: replace usage with a Lazy Cell + dashmap
87+
cached = "0.53.1" # FIXME: replace usage with a Lazy Cell + dashmap
8888
garde = "0.20"
8989
paste = "1.0.15"
9090

@@ -119,11 +119,12 @@ indexmap = { version = "2.6.0", features = ["serde"] }
119119
semver = "1.0.23"
120120
dashmap = "6.1.0"
121121
connection-string = "0.2.0"
122-
chrono = { version = "0.4.38", features = ["serde"] }
122+
chrono = { version = "0.4.38", features = ["serde"] }
123123
tera = { version = "1.20", default-features = false }
124124
ordered-float = "4.3.0"
125125
graphql-parser = "0.4.0"
126126
uuid = "1.10.0"
127+
rustpython-parser = "0.4.0"
127128

128129
# wasm
129130
wasmtime = "25.0.2"
@@ -153,7 +154,7 @@ tracing-unwrap = { version = "1.0.1", features = ["log-location"] }
153154
tracing-appender = "0.2.3"
154155

155156
# async
156-
futures = "=0.3.30" # pinned due to bug with .31 with zeromq (deno)
157+
futures = "=0.3.30" # pinned due to bug with .31 with zeromq (deno)
157158
futures-concurrency = "7.6"
158159
futures-lite = "2.3"
159160
tokio = { version = "1", features = ["parking_lot"] }
@@ -167,7 +168,9 @@ temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", rev
167168
# prisma
168169
query-core = { git = "https://github.com/metatypedev/prisma-engines", branch = "fix/version-compat" }
169170
query-connector = { git = "https://github.com/metatypedev/prisma-engines", branch = "fix/version-compat" }
170-
request-handlers = { git = "https://github.com/metatypedev/prisma-engines", features = ["all"], branch = "fix/version-compat" }
171+
request-handlers = { git = "https://github.com/metatypedev/prisma-engines", features = [
172+
"all",
173+
], branch = "fix/version-compat" }
171174
datamodel-renderer = { git = "https://github.com/metatypedev/prisma-engines", branch = "fix/version-compat" }
172175
user-facing-errors = { git = "https://github.com/metatypedev/prisma-engines", branch = "fix/version-compat" }
173176
query-engine-metrics = { git = "https://github.com/metatypedev/prisma-engines", branch = "fix/version-compat" }

src/typegate/engine/00_runtime.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ const Meta = {
8585
unregister: getOp("op_grpc_unregister"),
8686
callGrpcMethod: getOp("op_call_grpc_method"),
8787
},
88+
py_validation: {
89+
validate: getOp("op_validate"),
90+
},
8891
};
8992

9093
globalThis.Meta = Meta;

src/typegate/engine/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ tonic.workspace = true
6767
bytes.workspace = true
6868
protobuf.workspace = true
6969
protobuf-json-mapping.workspace = true
70+
rustpython-parser.workspace = true
7071

7172
[dev-dependencies]
7273
env_logger.workspace = true

0 commit comments

Comments
 (0)