Skip to content

Commit

Permalink
Remove fromlist argument
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Jan 24, 2024
1 parent b78a2e0 commit 0f4d898
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
8 changes: 2 additions & 6 deletions src/js/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,12 +474,8 @@ export class PyodideAPI {
* @param mod_name The name of the module to import
* @returns A PyProxy for the imported module
*/
static pyimport(mod_name: string, fromlist?: string[]): any {
const result = API.pyodide_base.pyimport_impl(mod_name, fromlist);
if (!fromlist) {
return result;
}
return Object.fromEntries(fromlist.map((val, idx) => [val, result[idx]]));
static pyimport(mod_name: string): any {
return API.pyodide_base.pyimport_impl(mod_name);
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/py/_pyodide/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,7 @@ def find_imports(source: str) -> list[str]:
return list(sorted(imports))


def pyimport_impl(path: str, fromlist: list[str] | None = None) -> Any:
if fromlist:
mod = __import__(path, fromlist=fromlist)
return [getattr(mod, name) for name in fromlist]

def pyimport_impl(path: str) -> Any:
[stem, *fromlist] = path.rsplit(".", 1)
res = __import__(stem, fromlist=fromlist)
if fromlist:
Expand Down

0 comments on commit 0f4d898

Please sign in to comment.