-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Allow enabling individual experimental features #13790
Conversation
This comment has been minimized.
This comment has been minimized.
Hm it looks like this causes a crash, I will try to fix. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hm, the second crash shows that we can't probably say |
Btw a simple repro for the crash is class E(Generic[T]):
def __init__(self, *args: Unpack[tuple[int, str]]) -> None: ...
E() Also while playing with this I have found two bugs in the class C:
def __init__(self, **kwds: Unpack) -> None: ... Instead we should give an error about missing type arg. Second, this doesn't substitute implicit T = TypeVar("T")
class TD(TypedDict, Generic[T]):
x: T
y: int
def foo(**kwds: Unpack[TD]) -> None: ... # Should be same as `TD[Any]`
foo(x="yes", y=42) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool!
Question: can we somehow bind feature ids to error codes?
So users won't have to memorize two separate things and their mappings?
Co-authored-by: Nikita Sobolev <[email protected]>
No, not really. Many features (in particular those that are relevant here like |
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: sublime_debugger (https://github.com/daveleroy/sublime_debugger)
- modules/core/event.py:5: error: "TypeVarTuple" is not supported by mypy yet [misc]
+ modules/core/event.py:5: error: "TypeVarTuple" support is experimental, use --enable-incomplete-feature=TypeVarTuple to enable [misc]
- modules/core/event.py:27: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/event.py:27: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/event.py:37: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/event.py:37: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/event.py:59: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/event.py:59: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/event.py:69: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/event.py:69: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/event.py:75: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/event.py:75: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/core.py:12: error: "TypeVarTuple" is not supported by mypy yet [misc]
+ modules/core/core.py:12: error: "TypeVarTuple" support is experimental, use --enable-incomplete-feature=TypeVarTuple to enable [misc]
- modules/core/core.py:30: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/core.py:30: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/core.py:33: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/core.py:33: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/core.py:36: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/core.py:36: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/core.py:42: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/core.py:42: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
- modules/core/core.py:51: error: "Unpack" is not supported yet, use --enable-incomplete-features [misc]
+ modules/core/core.py:51: error: "Unpack" support is experimental, use --enable-incomplete-feature=Unpack to enable [misc]
|
This fixes couple issues discovered in #13790: * A crash on empty `Unpack` * Wrong behavior with implicit generic `Any` The latter was actually caused by somewhat reckless handling of generic `TypedDict`s, wrong argument count was handled inconsistently there.
Ref #13685