Skip to content

Conversation

@thejchap
Copy link
Contributor

@thejchap thejchap commented Sep 24, 2025

Summary

Fixes astral-sh/ty#1241

  • support .value on single member enums
    • more context in this pr - for single-member enums, the type is an instance of the enum class. for multi-member enums, its a union of literals. handle the former
  • lightweight handling of arbitrary mixins (return Any)

Test Plan

new mdtests

@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

mypy_primer results

No ecosystem changes detected ✅

No memory usage changes detected ✅

@thejchap thejchap force-pushed the thejchap/enum-auto2 branch 2 times, most recently from 7208cf6 to 87548a3 Compare September 24, 2025 02:11
@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Sep 24, 2025
@thejchap thejchap force-pushed the thejchap/enum-auto2 branch 2 times, most recently from 184c132 to eb5cf24 Compare September 26, 2025 02:55
@thejchap thejchap marked this pull request as ready for review September 26, 2025 02:59
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you!

@thejchap thejchap marked this pull request as draft September 26, 2025 16:31
@thejchap thejchap force-pushed the thejchap/enum-auto2 branch from eb5cf24 to fc0bd30 Compare October 14, 2025 02:05
@thejchap thejchap force-pushed the thejchap/enum-auto2 branch 5 times, most recently from e1d9024 to d24b83b Compare November 8, 2025 18:57
@thejchap thejchap force-pushed the thejchap/enum-auto2 branch from d24b83b to b69c358 Compare November 8, 2025 19:16
@thejchap thejchap marked this pull request as ready for review November 8, 2025 23:34
@thejchap thejchap requested a review from AlexWaygood November 8, 2025 23:34
@thejchap
Copy link
Contributor Author

thejchap commented Nov 8, 2025

@AlexWaygood i think this is ready for another look!

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you!!

@AlexWaygood AlexWaygood added the bug Something isn't working label Nov 9, 2025
@AlexWaygood AlexWaygood changed the title [ty] handle more enum.auto() cases [ty] Fix incorrect inference of enum.auto() for enums with non-int mixins, and imprecise inference of enum.auto() for single-member enums Nov 9, 2025
@AlexWaygood
Copy link
Member

AlexWaygood commented Nov 10, 2025

@woodruffw, any idea why astral-bot isn't posting or editing any ecosystem-report comments on this PR? :-)

I'd love to double-check the ecosystem impact here before merging

@woodruffw
Copy link
Member

(Just synchronizing chat streams)

Yeah, I have a theory on what's causing this -- I've opened a tracking issue on the bot!

@woodruffw
Copy link
Member

woodruffw commented Nov 10, 2025

I've made a tentative fix for this, which is now in place -- I'm going to fast-forward this branch to confirm that it works.

Edit: appears to be working!

@AlexWaygood AlexWaygood merged commit f63a9f2 into astral-sh:main Nov 10, 2025
41 checks passed
dcreager added a commit that referenced this pull request Nov 11, 2025
* origin/main: (38 commits)
  [ty] Make implicit submodule imports only occur in global scope (#21370)
  [ty] introduce local variables for `from` imports of submodules in `__init__.py(i)` (#21173)
  [`ruff`] Ignore `str()` when not used for simple conversion (`RUF065`) (#21330)
  [ty] implement `typing.NewType` by adding `Type::NewTypeInstance`
  [ty] supress inlay hints for `+1` and `-1` (#21368)
  [ty] Use type context for inference of generic constructors (#20933)
  [ty] Improve generic call expression inference (#21210)
  [ty] supress some trivial expr inlay hints (#21367)
  [`configuration`] Fix unclear error messages for line-length values exceeding `u16::MAX` (#21329)
  [ty] Fix incorrect inference of `enum.auto()` for enums with non-`int` mixins, and imprecise inference of `enum.auto()` for single-member enums (#20541)
  [`refurb`] Detect empty f-strings (`FURB105`) (#21348)
  [ty] provide `import` completion when in `from <name> <name>` statement (#21291)
  [ty] elide redundant inlay hints for function args (#21365)
  Fix syntax error false positive on alternative `match` patterns (#21362)
  Add a new "Opening a PR" section to the contribution guide (#21298)
  [`flake8-simplify`] Fix SIM222 false positive for `tuple(generator) or None` (`SIM222`) (#21187)
  Rebuild ruff binary instead of sharing it across jobs (#21361)
  [ty] Fix `--exclude` and `src.exclude` merging (#21341)
  [ty] Add support for properties that return `Self` (#21335)
  Add upstream linter URL to `ruff linter --output-format=json` (#21316)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect inferences for .value property for enum members that use enum.auto()

3 participants