-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
3.11 StrEnum
members are reduced to str
in some cases
#3997
Comments
… a `StrEnum` subclass under certain circumstances. This was caused by a circular dependency in `ReprEnum` caused by pyright's validation of `__init_subclass__` as part of class type evaluation. This change moves this validation step from the type evaluator to the checker, eliminating the potential for circular dependencies and improving performance. This addresses #3997.
Thanks for the bug report and clear repro. This will be addressed in the next release. |
This is addressed in pyright 1.1.274, which I just published. It will also be included in a future release of pylance. |
@erictraut I believe this has resurfaced in v1.1.290:
|
Same repro steps as above? If the repro steps are different, please open a new issue. If they're the same, I'll reopen this one. |
They are the same. |
…types in some rare circumstances. The problem is due to a circular dependency in the `enum.pyi` type stub involving the `StrEnum`, `ReprEnum` and `EnumMeta` classes. The solution is to detect this case and defer evaluation to handle the circular dependency. This addresses #3997.
Yes, this was a regression introduced in another recent bug fix. Normally our tests prevent such regressions, but I haven't been able to repro this bug under conditions of our test suite. It's extremely dependent on the order in which evaluation occurs, and any small change in the ordering makes the problem go away. The underlying problem is caused by a circular dependency in the way that I've made our circular dependency detection logic more robust to accommodate this case. This will be included in the next release. |
Thank you for the detailed explanation. |
This is included in pyright 1.1.291, which I just published. It will also be included in a future release of pylance. |
Describe the bug
This is the most peculiar set of preconditions, but if all of the following are true:
click.group
orclick.command
and__main__
module and... then
StrEnum
members are reduced down to simplestr
s.I was not able to repro this if I renamed
__main__
, or if I used a locally-defined decorator, or if I did not call the function, or if I constructed a customStrEnum
by subclassingstr
andEnum
.To Reproduce
pkg
withnpx -y pyright --pythonversion 3.11
The output is:
Expected behavior
That
Foo.bar
would be of typeFoo
andsome_foos
of typeset[Foo]
.VS Code extension or command-line
CLI, 1.1.273
The text was updated successfully, but these errors were encountered: