-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Python 3.11 StrEnum error when member is named "title" #14494
Comments
Interesting... This is because In fact, the same can be observed when trying to use member names that shadow other methods of from enum import StrEnum
class BuggyEnum(StrEnum):
capitalize = "capitalize"
casefold = "casefold"
center = "center"
count = "count"
encode = "encode"
endswith = "endswith"
expandtabs = "expandtabs"
find = "find"
format = "format"
format_map = "format_map"
index = "index"
isalnum = "isalnum"
isalpha = "isalpha"
isascii = "isascii"
isdecimal = "isdecimal"
isdigit = "isdigit"
isidentifier = "isidentifier"
islower = "islower"
isnumeric = "isnumeric"
isprintable = "isprintable"
isspace = "isspace"
istitle = "istitle"
isupper = "isupper"
join = "join"
ljust = "ljust"
lower = "lower"
lstrip = "lstrip"
maketrans = "maketrans"
partition = "partition"
removeprefix = "removeprefix"
removesuffix = "removesuffix"
replace = "replace"
rfind = "rfind"
rindex = "rindex"
rjust = "rjust"
rpartition = "rpartition"
rsplit = "rsplit"
rstrip = "rstrip"
split = "split"
splitlines = "splitlines"
startswith = "startswith"
strip = "strip"
swapcase = "swapcase"
title = "title"
translate = "translate"
upper = "upper"
zfill = "zfill" This chucks out the following:
https://mypy-play.net/?mypy=latest&python=3.11&gist=d21b0840b2caefcb83142ca1f0d0b7ca |
This error is correct. You have an incompatible override, which creates unsound code. Consider:
|
Probably something that should be mentioned under the limitations in the documentation, if anyone cares enough to write a patch... 🤷🏻 |
Note, this behavior should now fixed upstream due to python/cpython#103600 |
Bug Report
Currently when running
mypy==0.991
on a Python 3.11 file that's usingStrEnum
, it errors unexpectedly on an specific named member on my code. In this case, the member only needed to be namedtitle
to get anIncompatible types in assignment
error.I realize python 3.11 support gh-12840 is still ongoing, but I thought I should report it to help others who might encounter this.
It might also be worth noting that it happens in older Python versions (tested on 3.10) when using strenum backport.
To Reproduce
Playground Gist URL: https://mypy-play.net/?mypy=latest&python=3.11&gist=910f75dbbd0c2ca484dc018a1983b654
Expected Behavior
No Errors
Actual Behavior
Your Environment
0.991
mypy main.py
mypy.ini
(and other config files):None
3.11.1
The text was updated successfully, but these errors were encountered: