Conversation
The plugin manager is imported for every command, but it imports the installer stack at module level. Installer, Locker, InstalledRepository and EnvManager are only needed to install project plugins, so they are imported where they are used.
Author
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Check List
Summary
Application._load_pluginsimportspoetry.plugins.plugin_manageron every command (unless--no-plugins). That module importsInstaller,Locker,InstalledRepository,EnvandEnvManagerat module level, but they are only needed to install project plugins. This moves them into the functions that use them, next to the existing localFactoryimports, andEnvgoes underTYPE_CHECKING.Numbers
Importing
poetry.plugins.plugin_managerin a fresh interpreter no longer loadspoetry.installation: 846 modules insys.modulesbefore, 245 after. CPU time of the import went from about 640 ms to 140 ms (best of 20), measured on a busy machine, so the absolute numbers are high but the ratio held across runs.Tests
Added a test that importing the plugin manager does not load
poetry.installation, like the one added in #11004. The mocks that patchedInstallerthroughplugin_managernow patchpoetry.installation.installer.Installer._execute, as other tests do.tests/plugins, mypy and pre-commit pass.In #11004 you preferred moving code into its own module over function-level imports. If you'd rather have
ProjectPluginCachemoved into a separate module with global imports, I'm happy to do that instead.This PR was written with the help of Claude Code. I reviewed and tested all changes before submitting.