| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
There was a problem hiding this comment.
It breaks LSP on 3.8 by not accepting **kwds, not sure about on 3.9 (will check the PR out locally later and see)
Sorry, something went wrong.
|
Looking into the LSP complaint on 3.9: stdlib/enum.pyi:85: error: Signature of "__prepare__" incompatible with supertype "type" [override] stdlib/enum.pyi:85: note: Superclass: stdlib/enum.pyi:85: note: def __prepare__(metacls, str, Tuple[type, ...], **kwds: Any) -> Mapping[str, object] stdlib/enum.pyi:85: note: Subclass: stdlib/enum.pyi:85: note: @classmethod stdlib/enum.pyi:85: note: def __prepare__(metacls, cls: str, bases: Tuple[type, ...], **kwds: Any) -> _EnumDict It goes away if you mark the args as positional-only, which seems incorrect: diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi
index 8ca0a5f8..0c4a2943 100644
--- a/stdlib/enum.pyi
+++ b/stdlib/enum.pyi
@@ -82,7 +82,7 @@ class EnumMeta(ABCMeta):
if sys.version_info >= (3, 9):
@classmethod
- def __prepare__(metacls, cls: str, bases: tuple[type, ...], **kwds: Any) -> _EnumDict: ... # type: ignore[override]
+ def __prepare__(metacls, __cls: str, __bases: tuple[type, ...], **kwds: Any) -> _EnumDict: ...
else:
@classmethod
def __prepare__(metacls, cls: str, bases: tuple[type, ...]) -> _EnumDict: ... # type: ignore[override]
(Also the error message seems to drop the classmethod on the superclass, but based on tests I think that might just be a reporting issue). So I'm happy to chalk this up to mypy bug. |
Sorry, something went wrong.
|
Thanks for checking! Wasn't there some bug where the @classmethod decorator in this message sometimes gets eaten by the cache? Anyway, this does look like a mypy bug. |
Sorry, something went wrong.
|
I mean I guess technically mypy has a point in that: x.__prepare__(metaclass, cls, bases, cls=100) will get you a TypeError if it turns out your x is an EnumMeta and not a type. But I'm guessing the complaint might not be intentional. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I don't really understand why this needs the # type: ignores, but mypy seems absolutely convinced that this method breaks LSP!