Repository navigation
perf: Avoid scanning installed packages in package_version - #8191
Jackevansevo wants to merge 3 commits into
Conversation
30fc342 to
3f7480b
Compare
4fa731a to
3f7480b
Compare
|
Hey @Jackevansevo, thanks for the PR. The change itself is good, but it's very targeted (just to Flask). Is there a way to generalize it so that any integration that needs a version check first checks via the less expensive route? |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3f7480b to
ea2c4c6
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thanks for the feedback. I've moved the fast path check into
If It's worth flagging here that if we skip calling But only integrations using |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f47e6a4. Configure here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Description
package_versionparsed every installed package's metadata to read one version. It now looks up only that package, as suggested in #2316, which covers all 7 places that call it.Same scan as #6865 (fixed there for MCP only), and the same lookup as the
pydantic_aiintegration (directimportlib.metadatacall).#2338 chose the cached list because
importlib.metadataneeds Python 3.8+. That path stays as the fallback, so this only avoids the first scan's cost.ModulesIntegrationstill builds the full list on the first error event.With ~250 packages,
package_version("flask")goes from 106 ms to 5 ms (-95%).Draft: the test suite hasn't been run on this yet.
Issues
package_version()parses every installed package's metadata, slowingsentry_sdk.init()#8190🤖 Generated with Claude Code