Skip to content

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented Jul 11, 2025

Summary

Adds a way to list all members of an Enum and implements almost all of the mechanisms by which members are distinguished from non-members (spec). This has no effect on actual enums, so far.

If we're not comfortable merging this without having an actual impact, I can also just use this as a basis for further features.

Test Plan

New Markdown tests using ty_extensions.enum_members.

@sharkdp sharkdp added the ty Multi-file analysis & type inference label Jul 11, 2025
};

/// List all members of an enum.
pub(crate) fn enum_members<'db>(db: &'db dyn Db, class: &'db ClassLiteral<'db>) -> Vec<String> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will certainly have a richer return type in the future. For now, just return a list of strings to power the ty_extensions.enum_members functionality.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 11, 2025

mypy_primer results

No ecosystem changes detected ✅
No memory usage changes detected ✅

@AlexWaygood AlexWaygood added the testing Related to testing Ruff itself label Jul 11, 2025
@sharkdp sharkdp merged commit f22da35 into main Jul 14, 2025
37 checks passed
@sharkdp sharkdp deleted the david/enums branch July 14, 2025 11:18
dcreager added a commit that referenced this pull request Jul 14, 2025
* dcreager/merge-arguments: (223 commits)
  fix docs
  Combine CallArguments and CallArgumentTypes
  [ty] Sync vendored typeshed stubs (#19334)
  [`refurb`] Make example error out-of-the-box (`FURB122`) (#19297)
  [refurb] Make example error out-of-the-box (FURB177) (#19309)
  [ty] ignore errors when reformatting codemodded typeshed (#19332)
  [ty] Provide docstrings for stdlib APIs when hovering over them in an IDE (#19311)
  [ty] Add virtual files to the only project database (#19322)
  Add t-string fixtures for rules that do not need to be modified (#19146)
  [ty] Remove `FileLookupError` (#19323)
  [ty] Fix handling of metaclasses in `object.<CURSOR>` completions
  [ty] Use an interval map for scopes by expression (#19025)
  [ty] List all `enum` members (#19283)
  [ty] Handle configuration errors in LSP more gracefully (#19262)
  [ty] Use python version and path from Python extension (#19012)
  [`pep8_naming`] Avoid false positives on standard library functions with uppercase names (`N802`) (#18907)
  Update Rust crate toml to 0.9.0 (#19320)
  [ty] Fix server version (#19284)
  Update NPM Development dependencies (#19319)
  Update taiki-e/install-action action to v2.56.13 (#19317)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants