Skip to content

Python: bump ty-types to 0.0.39, handle EnumComplement#7789

Merged
knutwannheden merged 1 commit into
mainfrom
wiry-otter
May 27, 2026
Merged

Python: bump ty-types to 0.0.39, handle EnumComplement#7789
knutwannheden merged 1 commit into
mainfrom
wiry-otter

Conversation

@knutwannheden
Copy link
Copy Markdown
Contributor

Motivation

ty-types v0.0.39 introduces a new enumComplement TypeDescriptor kind, representing an enum type narrowed by excluding specific members (e.g. the type of c after if c is not Color.RED: is Color & ~Literal[Color.RED]). Without explicit handling, the Python type mapper falls through to _UNKNOWN, dropping type attribution for narrowed enum variables.

Java's type system has no equivalent of literal or subtraction types, so mapping enumComplement follows the same approach as the existing enumLiteral handling: collapse to the underlying enum class type. The excluded-members information is intentionally not preserved on the LST — recipes that need that level of detail should consult the Python AST directly.

See https://github.com/openrewrite/ty-types/releases/tag/v0.0.39 for the upstream release notes.

Summary

  • Bump ty-types from >=0.0.31 to >=0.0.39.
  • Map the new enumComplement TypeDescriptor to the underlying enum JavaType.Class (same handling as enumLiteral).

Test plan

  • pytest tests/python/all/tree/import_test.py (16/16 pass)

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite May 27, 2026
@knutwannheden knutwannheden changed the title Python: bump ty-types to 0.0.39, handle EnumComplement Python: bump ty-types to 0.0.39, handle EnumComplement May 27, 2026
@knutwannheden knutwannheden merged commit 6bebc5e into main May 27, 2026
1 check passed
@knutwannheden knutwannheden deleted the wiry-otter branch May 27, 2026 07:38
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant