Skip to content

Include instance attributes in workspace symbol search - #4897

Open
dantrapp wants to merge 2 commits into
facebook:mainfrom
dantrapp:fix/workspace-symbol-instance-attributes
Open

dantrapp wants to merge 2 commits into
facebook:mainfrom
dantrapp:fix/workspace-symbol-instance-attributes

Conversation

@dantrapp

Copy link
Copy Markdown

Summary

Workspace symbol search misses attributes initialized in method bodies, including self._private_member = 1 from #4688. The existing search already finds _private_method. This change adds receiver-attribute assignments to the cached flat symbol table, returning the attribute's name location with its enclosing class as the container.

The collector handles ordinary and annotated assignments, chained assignments, and unpacking. It excludes function locals, unrelated object targets, and syntactically marked static methods, and resets receiver tracking at nested function/class boundaries. Auto-imports still use the unchanged export table.

The collector remains syntax-based: it recognizes @staticmethod and qualified .staticmethod decorators, but does not resolve decorator aliases or track receiver rebinding.

Fixes #4688.

Test Plan

  • First commit (9153364) reproduces the failure: the method control passes, while the instance-attribute test returns zero matches and fails.
  • cargo test -p pyrefly --lib workspace_symbol: 16 passed, including workspace-symbol protocol tests and lightweight tests for both Require::Everything and Require::Indexing.
  • cargo test -p pyrefly --lib export::: 44 passed, including assignment forms, receiver scope, and static-method exclusions.
  • cargo test -p pyrefly --lib test::lsp::completion::: 142 passed.
  • python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema: passed.
  • cargo build -p pyrefly: passed; the executable reports pyrefly 1.3.0-dev.4.

Local validation used Rust 1.96.0. Unrelated formatter changes to existing imports in test/pydantic/util.rs and test/suppression.rs were excluded from this PR. The full cross-platform suite is left to CI.

AI assistance: OpenAI Codex performed the investigation, implementation, and test execution.

@meta-cla

meta-cla Bot commented Sep 10, 2026

Copy link
Copy Markdown

Hi @dantrapp!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Sep 10, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the cla signed label Sep 10, 2026
@meta-cla

meta-cla Bot commented Sep 10, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-codesync

meta-codesync Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@kinto0 has imported this pull request. If you are a Meta employee, you can view this in D119740446. (Because this pull request was imported automatically, there will not be any future comments.)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workspace/symbol does not return attributes defined in __init__

2 participants