Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RefactorPlatforms/WASI/__main__.py for lazy importing and future new subcommands#145404

Open
brettcannon wants to merge 11 commits intopython:mainfrom
brettcannon:wasi-refactor
Open

RefactorPlatforms/WASI/__main__.py for lazy importing and future new subcommands#145404
brettcannon wants to merge 11 commits intopython:mainfrom
brettcannon:wasi-refactor

Conversation

@brettcannon
Copy link
Member

Everything related to thebuild subcommand & friends has been moved into a_build module which is now lazily imported in__main__ which now only handles argparse. This did require tweaking what the defaults are in the argument parser so that it didn't trigger needing to import_build. It also required changing dispatching to subcommands from a dict to amatch statement to also avoid triggering the import of_build. As well, all imports in_build that are not needed for every subcommand has also been made lazy. Since neither PEP 8 or Ruff/Black have decided how to sort lazy imports, they are interleaved and imports are sorted by name as if thelazy aspect of the statement wasn't there.

This work also sets things up so that any future subcommands can go into their own module and also be lazily imported into__main__.

@hugovk
Copy link
Member

Since neither PEP 8 or Ruff/Black have decided how to sort lazy imports,

Ruff and isort issues:

they are interleaved and imports are sorted by name as if thelazy aspect of the statement wasn't there.

Although this PR is using__lazy_modules__ and not thelazy keyword.

brettcannonand others added2 commitsMarch 2, 2026 09:09
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@hugovk
Copy link
Member

Now we have this duplicate:

      -id:ruff-checkname:Run Ruff (lint) on Tools/build/args:[--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]files:^Tools/build/      -id:ruff-checkname:Run Ruff (lint) on Tools/build/args:[--exit-non-zero-on-fix, --config=Tools/build/.ruff.toml]files:^Tools/build/
brettcannon reacted with confused emoji

@brettcannon
Copy link
MemberAuthor

they are interleaved and imports are sorted by name as if thelazy aspect of the statement wasn't there.

Although this PR is using__lazy_modules__ and not thelazy keyword.

Correct! (The initial version did, but I realized backporting would not be fun withlazy, so I went with__lazy_modules__.)

Maybe that will help define what to do withlazy as sorting differently based on whether__lazy_modules__ orlazy is used might be a little too weird.

hugovk reacted with thumbs up emoji

@bedevere-app
Copy link

When you're done making the requested changes, leave the comment:I have made the requested changes; please review again.

@brettcannon
Copy link
MemberAuthor

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@savannahostrowski,@hugovk: please review the changes made to this pull request.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@emmatypingemmatypingAwaiting requested review from emmatypingemmatyping is a code owner

@hugovkhugovkAwaiting requested review from hugovkhugovk is a code owner

@savannahostrowskisavannahostrowskiAwaiting requested review from savannahostrowskisavannahostrowski is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@brettcannon@hugovk@savannahostrowski

[8]ページ先頭

©2009-2026 Movatter.jp