Skip to content

Fix #13674: do not evaluate @property getters during Jedi completion - #15476

Open
zheng-guannan577 wants to merge 2 commits into
ipython:mainfrom
zheng-guannan577:fix-13674-jedi-property
Open

zheng-guannan577 wants to merge 2 commits into
ipython:mainfrom
zheng-guannan577:fix-13674-jedi-property

Conversation

@zheng-guannan577

Copy link
Copy Markdown

Fixes #13674

Problem

Completing attributes of a @Property value (e.g. f.yo.<tab>) made Jedi evaluate the getter at runtime for live namespace objects, bypassing the completer's evaluation policy (the non-Jedi path already refuses the access under limited).

Note: the exact f.<tab> repro from 2022 is already fixed on main by the guarded-eval machinery; this PR fixes the remaining live instance, f.yo.<tab> via Jedi.

Fix

IPCompleter._jedi_matches now skips Jedi when the attribute chain before the cursor ends in a property on a live namespace object, detected with inspect.getattr_static so the check itself never invokes the getter. cached_property is covered the same way (unless already cached). Under unsafe/dangerous evaluation the getter is still allowed, matching the non-Jedi matchers.

Tests

  • test_jedi_does_not_evaluate_property — f. lists yo without calling the getter; f.yo. gives no completions under limited and int completions under unsafe.

🤖🤖 AI 辅助起草 — This contribution was drafted with AI assistance; the analysis, the change and the tests are described above so that they can be reviewed.

🤖🤖 AI 辅助起草 — This contribution was drafted with AI assistance; the analysis, the change and the tests are described above so that they can be reviewed.
🤖🤖 AI 辅助起草 — This contribution was drafted with AI assistance; the analysis, the change and the tests are described above so that they can be reviewed.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tab completion executes @property getter function

1 participant