-
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
Walrus operator causes no overload match for str.join
in dataclass
#9659
Comments
…ion (walrus operator) is used as an argument to a constructor call when the constructor has both a `__new__` and `__init__` with differing bidirectional type inference contexts. This addresses #9659.
Thanks for the bug report. The reason this happens with a dataclass and not the class in your example is that the dataclass has both an If I add a from typing import Any, Self
class T_normal:
def __new__(cls, *args: Any, **kwargs: Any) -> Self: ...
def __init__(self, base: list[str], joined: str): ...
T_normal(base=(b := ["abc", "def"]), joined=" ".join(b)) In case you're interested in the details... The bug is related to the way that pyright internally caches the type of a subexpression once it is evaluated. In this case, the subexpression This will be addressed in the next release. |
This is addressed in pyright 1.1.392. |
Describe the bug
Pyright reports an error when a walrus operator is used while passing a variable to
str.join
and then to a dataclass.The error is:
No overloads for "join" match the provided arguments
.Code or Screenshots
Similar code with no error
VS Code extension or command-line
Error detected in VS Code by Pylance. Pylance version is
2024.12.1
.Also, the error is replicated in pyright playground for version
1.1.391
.The text was updated successfully, but these errors were encountered: