Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use assignments for enums in pillow #11959

Merged
merged 3 commits into from
May 19, 2024
Merged

Conversation

hamdanal
Copy link
Contributor

@hamdanal hamdanal commented May 18, 2024

Follow up to #11957 and #11956.

With this change, typeshed becomes ready for the change in the type checker behavior regarding unassigned enum attributes.

Edit: pygit2 changes have been split to a separate PR

ROTATE_270: Literal[4]
TRANSPOSE: Literal[5]
TRANSVERSE: Literal[6]
FLIP_LEFT_RIGHT: Final = 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to use the enum value here like this FLIP_LEFT_RIGHT: Final = Transpose.FLIP_LEFT_RIGHT.value but pytype complained.

stubs/pygit2/pygit2/enums.pyi Outdated Show resolved Hide resolved

This comment has been minimized.

Comment on lines 222 to 238
UYVY = i32(b"UYVY")
R8G8_B8G8 = i32(b"RGBG")
YUY2 = i32(b"YUY2")
G8R8_G8B8 = i32(b"GRGB")
DXT1 = i32(b"DXT1")
DXT2 = i32(b"DXT2")
DXT3 = i32(b"DXT3")
DXT4 = i32(b"DXT4")
DXT5 = i32(b"DXT5")
DX10 = i32(b"DX10")
BC4S = i32(b"BC4S")
BC4U = i32(b"BC4U")
BC5S = i32(b"BC5S")
BC5U = i32(b"BC5U")
ATI1 = i32(b"ATI1")
ATI2 = i32(b"ATI2")
MULTI2_ARGB8 = i32(b"MET1")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why none of our tests complained, but I doubt this will work. We just need to use the generated int value and possibly add a comment with the "source" value.

@hamdanal hamdanal changed the title Use assignments for enums in pillow and pygit2 Use assignments for enums in pillow May 19, 2024
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit 08b9c86 into python:main May 19, 2024
42 checks passed
@hamdanal hamdanal deleted the enum-pillow-pygit2 branch May 19, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants