-
-
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
Fix crash on ParamSpec unification #16251
Fix crash on ParamSpec unification #16251
Conversation
There's a slightly mysterious-looking test failure in a mypyc test. Possibly unrelated to this diff; let's see if it also happens on #12661 where I just retriggered CI. |
This comment has been minimized.
This comment has been minimized.
@JelleZijlstra It passed on retry LOL. Actually, I think it is the second time Python 3.8 MacOS randomly flakes during last week (and a different test case IIRC, but can't find logs now). |
I also had segfault and this branch does not solve it. here's offending code
here is part of stack trace (infinite recursion)
seems some other function that you fixes is also affected here's the minimum modification of the code above that prevents segfault
hope this helps |
No, it still fails with:
https://github.com/dry-python/returns/actions/runs/6492022546/job/17630240757?pr=1702 At least, I can see the traceback now :) |
Oops, yes, same thing for plain callables (I will also do a small refactoring while I am at this). |
Diff from mypy_primer, showing the effect of this PR on open source code: discord.py (https://github.com/Rapptz/discord.py)
- discord/app_commands/commands.py:2381: error: "Callable[..., Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__" [attr-defined]
- discord/app_commands/commands.py:2383: error: "Callable[..., Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__" [attr-defined]
+ discord/app_commands/commands.py:2381: error: Item "function" of "Callable[[Any, Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__" [union-attr]
+ discord/app_commands/commands.py:2383: error: Item "function" of "Callable[[Any, Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]] | Callable[[Interaction[Any], VarArg(Any), KwArg(Any)], Coroutine[Any, Any, Any]]" has no attribute "__discord_app_commands_checks__" [union-attr]
|
Happy to confirm that this fixes the typeshed crash! I tested by installing this PR branch into a venv with all of typeshed's other test requirements, making this change to --- a/tests/utils.py
+++ b/tests/utils.py
@@ -83,8 +83,8 @@ def make_venv(venv_dir: Path) -> VenvInfo:
@cache
def get_mypy_req() -> str:
- with open("requirements-tests.txt", encoding="UTF-8") as requirements_file:
- return next(strip_comments(line) for line in requirements_file if "mypy" in line)
+ return "git+https://github.com/ilevkivskyi/mypy.git@fix-paramspec-regression"
+ |
@ilevkivskyi yeah now it works! thank you for quick fix! |
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.
Thanks for the quick fix!
I tried |
Fixes #16245 Fixes #16248 Unfortunately I was a bit reckless with parentheses, but in my defense `unify_generic_callable()` is kind of broken for long time, as it can return "solutions" like ```{1: T`1}```. We need a more principled approach there (IIRC there is already an issue about this in the scope of `--new-type-inference`). (The fix is quite trivial so I am not going to wait for review too long to save time, unless there will be some issues in `mypy_primer` etc.)
Fixes #16245
Fixes #16248
Unfortunately I was a bit reckless with parentheses, but in my defense
unify_generic_callable()
is kind of broken for long time, as it can return "solutions" like{1: T`1}
. We need a more principled approach there (IIRC there is already an issue about this in the scope of--new-type-inference
).(The fix is quite trivial so I am not going to wait for review too long to save time, unless there will be some issues in
mypy_primer
etc.)