diff --git a/src/typegate/engine/src/py_validation.rs b/src/typegate/engine/src/py_validation.rs index 8a40cdf6b..107645aeb 100644 --- a/src/typegate/engine/src/py_validation.rs +++ b/src/typegate/engine/src/py_validation.rs @@ -18,11 +18,7 @@ fn read_file(path: &str) -> Result { #[deno_core::op2(fast)] pub fn op_validate(#[string] input: String) -> Result<()> { - if let Some(file_name) = input.split(".").last() { - if file_name == "py" { - let python_source = read_file(&input)?; - ast::Suite::parse(&python_source, "")?; - } - } + let python_source = read_file(&input)?; + ast::Suite::parse(&python_source, "")?; Ok(()) } diff --git a/src/typegate/src/runtimes/python/hooks/mod.ts b/src/typegate/src/runtimes/python/hooks/mod.ts index 52c5a55d3..1a02a48e8 100644 --- a/src/typegate/src/runtimes/python/hooks/mod.ts +++ b/src/typegate/src/runtimes/python/hooks/mod.ts @@ -38,26 +38,28 @@ export const codeValidations: PushHandler = async ( depMetas, ); - try { - logger.info( - `Validating Python code at entry point: ${entryPoint.path}`, - ); - Meta.py_validation.validate(entryModulePath); + if (entryModulePath.split(".").slice(-1)[0] == "py") { + try { + logger.info( + `Validating Python code at entry point: ${entryPoint.path}`, + ); + Meta.py_validation.validate(entryModulePath); - for (const dep of depMetas) { - const depPath = await artifactStore.getLocalPath(dep); - logger.info(`Validating Python code for dependency: ${depPath}`); - Meta.py_validation.validate(depPath); - } + for (const dep of depMetas) { + const depPath = await artifactStore.getLocalPath(dep); + logger.info(`Validating Python code for dependency: ${depPath}`); + Meta.py_validation.validate(depPath); + } - logger.info( - `Successfully validated Python code at entry point: ${entryPoint.path}`, - ); - } catch (err) { - console.error({ err }); - throw new ValidationFailure( - `Python code validation error at entry point '${entryPoint.path}': ${err.message}`, - ); + logger.info( + `Successfully validated Python code at entry point: ${entryPoint.path}`, + ); + } catch (err) { + console.error({ err }); + throw new ValidationFailure( + `Python code validation error at entry point '${entryPoint.path}': ${err.message}`, + ); + } } } }