test: document enum semantic-token classification bugs (#5050)

Summary:
Semantic tokens classify attributes from their inferred value types instead of their definitions. Snapshots capture the current misclassification, with comments identifying the correct enumMember or property token for each affected case.

These LSP tests use ordinary Rust `#[test]` functions, so explicit `BUG` comments document the incorrect behavior and the correct result. These are passing tests of known bugs, following [the repository test guidance](https://github.com/facebook/pyrefly/blob/main/AGENTS.md#the-bug-marker-in-tests).

The complete implementation and regression tests remain in [PR https://github.com/facebook/pyrefly/issues/4794](https://github.com/facebook/pyrefly/pull/4794). Related issue: https://github.com/facebook/pyrefly/issues/4751.

## Validation

Based on upstream `main` at `ef6de648bce0dc6dcca0a21a9fbb7490f23ecce8`.

- `cargo test -p pyrefly --lib -- enum_member_definition_test narrowed_enum_instance_attribute_test` — passed.
- `python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension` — passed.

Pull Request resolved: https://github.com/facebook/pyrefly/pull/5050

Reviewed By: rchen152

Differential Revision: D122390462

fbshipit-source-id: 79027859a79c700aca570d74df86de37bf3e66de
1 file changed
tree: 26be97a0d14bbd6dfbca4630cbd095d17defa11f
  1. .agents/
  2. .cargo/
  3. .claude/
  4. .github/
  5. .llms/
  6. .vscode/
  7. conformance/
  8. crates/
  9. lsp/
  10. pyrefly/
  11. pyrefly_wasm/
  12. release_notes/
  13. schemas/
  14. scripts/
  15. tensor-shapes/
  16. test/
  17. website/
  18. .gitattributes
  19. .gitignore
  20. action.yml
  21. AGENTS.md
  22. AI_POLICY.md
  23. ARCHITECTURE.md
  24. Cargo.lock
  25. Cargo.toml
  26. CODE_OF_CONDUCT.md
  27. CONTRIBUTING.md
  28. debug.html
  29. empty.py
  30. LICENSE
  31. package-lock.json
  32. README.md
  33. ruff.toml
  34. rust-toolchain.toml
  35. rustfmt.toml
  36. TENSOR_SHAPES_CONTRIBUTING.md
  37. test.py
  38. version.bzl
  39. yarn.lock
README.md

Pyrefly: A fast type checker and language server for Python with powerful IDE features

pyrefly PyPI VS Code Open VSX Discord License: MIT

Pyrefly is a type checker and language server for Python, which provides lightning-fast type checking along with IDE features such as code navigation, semantic highlighting, and code completion. It is available as a command-line tool and an extension for popular IDEs and editors such as VSCode, Neovim, Zed, and more.

See the Pyrefly website for full documentation and how to add Pyrefly to your editor of choice.

Pyrefly's current development status is stable.

Key Features

  • Fast. Pyrefly checks over 1.85 million lines of code per second, type checking projects like PyTorch 15x faster than Mypy and Pyright. In the IDE, rechecks typically complete in under 10 milliseconds after saving a file.
  • Production-proven at scale. Pyrefly is the default type checker for Instagram's 20-million-line Python codebase at Meta, and has been adopted by large open source projects including PyTorch and JAX.
  • Full-featured language server. Code navigation, autocomplete, hover information, inlay hints, semantic highlighting, and more, with consistent results across the CLI and your editor of choice.
  • Understands real-world Python. Built-in support for frameworks and tools like Pydantic, Django, and pytest, with model validation, field types, fixture navigation, and autocomplete that work out of the box.
  • Adoption-ready. Migrate from Mypy or Pyright with pyrefly init, silence existing errors with pyrefly suppress, and generate type annotations with pyrefly infer. Start with one file and expand at your own pace.

Getting Started

Version Policy

Pyrefly releases new minor versions (1.x.0) monthly and patch versions in between as-needed for critical fixes. Pyrefly does not follow strict semantic versioning: minor versions contain more significant changes than patch versions, but any version may introduce new type errors and other breaking changes. The pyrefly suppress command can be used to easily silence errors when upgrading to a new version.

Getting Involved

If you have questions or would like to report a bug, please create an issue.

See our contributing guide and architecture overview for information on how to contribute to Pyrefly.

Join our Discord to chat about Pyrefly and types. This is also where we hold biweekly office hours.