refactor py-config to use json (#754)

* refactor py-config to use toml

* switch from toml to json and add unit tests

* fix test for py-config

* fix integration test

* use flat structure for JSON

* allow merging configs

* replace arrays instead of concatenating them

* remove extra keys from inline config of integration test

* simplify array replacement logic

* allow config from src to be partial as well

* add comments to unit tests

* add unit test for setting config from both inline and src

* handle parse errors + validate config supplied

* separate functions for src and inline

* suggested improvements

* show error message in red on parser error

* fix eslint

* use resolveJsonModule as true

* use default config defined as a variable without import

* remove disable eslint comment

* remove import for covfefe.json as well

* metadata injection

* add support for schema + extra keys

* use schema_version
This commit is contained in:
Madhur Tandon
2022-09-16 02:07:00 +05:30
committed by GitHub
parent 0b014eea56
commit 4841e29fc6
8 changed files with 330 additions and 46 deletions

View File

@@ -8,12 +8,6 @@ import pyscript from './python/pyscript.py';
const logger = getLogger('pyscript/pyodide');
export const DEFAULT_RUNTIME_CONFIG: RuntimeConfig = {
src: 'https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js',
name: 'pyodide-default',
lang: 'python'
};
export class PyodideRuntime extends Runtime {
src: string;
name?: string;
@@ -22,9 +16,9 @@ export class PyodideRuntime extends Runtime {
globals: any;
constructor(
src = DEFAULT_RUNTIME_CONFIG.src,
name = DEFAULT_RUNTIME_CONFIG.name,
lang = DEFAULT_RUNTIME_CONFIG.lang,
src = 'https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js',
name = 'pyodide-default',
lang = 'python',
) {
logger.info('Runtime config:', { name, lang, src });
super();