Skip to content
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

Argument of type "QueryInstance" cannot be assigned to parameter "cond" of type "QueryLike" #496

Closed
saumikn opened this issue Nov 26, 2022 · 2 comments

Comments

@saumikn
Copy link

saumikn commented Nov 26, 2022

Using the VS Code Pylance type checker, I'm unable to run queries without giving me type errors. For example, just running db.search(where("field") == field) gives me the error:

Argument of type "QueryInstance" cannot be assigned to parameter "cond" of type "QueryLike" in function "search"
  "QueryInstance" is incompatible with protocol "QueryLike"
    "__hash__" is an incompatible type
      Type "() -> int" cannot be assigned to type "() -> None"
        Function return type "int" is incompatible with type "None"
          Type cannot be assigned to type "None"Pylance[reportGeneralTypeIssues](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportGeneralTypeIssues)

I can fix this if I go into queries.QueryLike, and replace def __hash__(self): ... with def __hash__(self) -> int: ...

If we made this change, would it break other code (e.g. MyPy) in any way?

@msiemens
Copy link
Owner

Seems like MyPy wasn't too upset about this, so I've added this change in b431412 🙂 (Note that the CI pipeline fails due to issues unrelated to this change). Will be released in the next TinyDB version

@saumikn
Copy link
Author

saumikn commented Nov 26, 2022

Oh, turns out I was referring to a line which was already fixed in fcb1a86, just that that change hasn't been released yet so it never showed up on my end. Thanks for the quick reply!

@saumikn saumikn closed this as completed Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants