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

functional syntax for enum not implemented #574

Closed
dlinnemeyer opened this issue Sep 26, 2016 · 3 comments
Closed

functional syntax for enum not implemented #574

dlinnemeyer opened this issue Sep 26, 2016 · 3 comments

Comments

@dlinnemeyer
Copy link
Contributor

dlinnemeyer commented Sep 26, 2016

https://docs.python.org/3/library/enum.html#functional-api

I'm getting Too many arguments for "Enum" from mypy. I'm guessing it needs an __init__ function?

Not sure how this should be handled. It's dynamic, so I take it there's no real way to provide type safety for this syntax? But maybe something should be done to not throw an error when it is used?

@gvanrossum
Copy link
Member

I believe that this is actually a deficiency in mypy's special-casing of enums. As long as the argument is a literal (not a dynamically constructed string) this could be made to work by special-casing this. See e.g. python/mypy#529 (comment)

I'm closing this here because I don't think a change to typeshed would be sufficient (though it might be needed too).

@MartinThoma
Copy link

I'm confused by this issue. I currently run into the same error (Too many arguments for "Enum"). What should I do?

System Info

  • Python 3.8.1
  • mypy==0.781

@JelleZijlstra
Copy link
Member

@MartinThoma mypy supports at least some versions of the functional enum API (python/mypy#2805). If some variation doesn't work for you yet, you should report an issue to mypy (not typeshed) with the exact code that is not working.

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

No branches or pull requests

4 participants