Python: bump ty-types to 0.0.39, handle EnumComplement#7789
Merged
Conversation
ty-types to 0.0.39, handle EnumComplement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ty-types v0.0.39 introduces a new
enumComplementTypeDescriptorkind, representing an enum type narrowed by excluding specific members (e.g. the type ofcafterif c is not Color.RED:isColor & ~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
enumComplementfollows the same approach as the existingenumLiteralhandling: 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
ty-typesfrom>=0.0.31to>=0.0.39.enumComplementTypeDescriptorto the underlying enumJavaType.Class(same handling asenumLiteral).Test plan
pytest tests/python/all/tree/import_test.py(16/16 pass)