You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A static type checker fails because of filter argument type.
Type "dict[str, str]" cannot be assigned to type "Dict[str, str | float | int | bool | List[Unknown] | dict[Unknown, Unknown]] | None"
"dict[str, str]" is incompatible with "Dict[str, str | float | int | bool | List[Unknown] | dict[Unknown, Unknown]]
Expected Behavior
The dictionary passed in the filter argument is not changed in the query function, therefore we could use covariant Mapping type instead of Dict, so the type checker doesn't throw.
% pyright main.py
/Users/****/main.py
/Users/****/main.py:17:12 - error: Argument of type"dict[str, str]" cannot be assigned to parameter "filter" of type"Dict[str, str | float | int | bool | List[Unknown] | dict[Unknown, Unknown]] | None"infunction"query"
Type "dict[str, str]" cannot be assigned to type"Dict[str, str | float | int | bool | List[Unknown] | dict[Unknown, Unknown]] | None""dict[str, str]" is incompatible with "Dict[str, str | float | int | bool | List[Unknown] | dict[Unknown, Unknown]]"
Type parameter "_VT@dict" is invariant, but "str" is not the same as "str | float | int | bool | List[Unknown] | dict[Unknown, Unknown]"
Consider switching from "dict" to "Mapping" which is covariant in the value type"dict[str, str]" is incompatible with "None" (reportArgumentType)
1 error, 0 warnings, 0 informations
Thyrst
changed the title
[Bug] Using Mapping instead of Dict for read-only arguments
[Bug] Use Mapping instead of Dict for read-only arguments
Feb 6, 2024
Is this a new bug in the Pinecone Python client?
Current Behavior
I query Pinecone index like this:
A static type checker fails because of filter argument type.
Expected Behavior
The dictionary passed in the filter argument is not changed in the query function, therefore we could use covariant Mapping type instead of Dict, so the type checker doesn't throw.
Steps To Reproduce
pip install pinecone-client pyright
main.py
:pyright main.py
Relevant log output
Environment
Additional Context
I think covariant types should be used preferably for the input arguments everywhere where the passed objects are not changed.
The text was updated successfully, but these errors were encountered: