Guys, I have a question: Why would vscode complain about this?
Last active a month ago
29 replies
5 views
- TA
Guys, I have a question: Why would vscode complain about this?
- AN
hi! how do you import models?
- TA
from qdrant_client import QdrantClient, models
- TA
I'm missing something?
- DA
Python 3.9 is giving this error. Pylance.
- DA
3.10 is ok.
- TA
I'm using python3.8.15
- AN
does it work if you run it?
- DA
https://docs.pydantic.dev/usage/models/#required-fields
- DA
```class Model(BaseModel):
a: Optional[int]
b: Optional[int] = …
c: Optional[int] = Field(…)In this model, a, b, and c can take None as a value. But a is optional, while b and c are required. b and c require a value, even if the value is None.```
- DA
In this model, a, b, and c can take None as a value. But a is optional, while b and c are required. b and c require a value, even if the value is None.
- DA
This is because of the declaration.
- DA
Field is declared explictly. So Pylance "thinks" it's a required field which can accept None
- DA
match: Optional["Match"] = Field(None, description="Check if point has field with a given value") range: Optional["Range"] = Field(None, description="Check if points value lies in a given range") geo_bounding_box: Optional["GeoBoundingBox"] = Field( None, description="Check if points geo location lies in a given area" ) geo_radius: Optional["GeoRadius"] = Field(None, description="Check if geo point is within a given radius") values_count: Optional["ValuesCount"] = Field(None, description="Check number of values of the field")
- TA
yes
- TA
@danielbichuetti On what version of python 3.10 worked for you? I've just switched to python 3.10.8 and the error from Pylance is still there
- AN
Hi! we recently updated pylance types, could you please try v0.11.10 of the client?
- TA
- TA
hmm .. i'm still getting the error .. even if I can see that the Filter class from the models.py has it's field defaulted to None
- TA
it's strange that i'm still getting this error
- TA
- AN
👁️
- DA
When using Pydantic, if you declare a field as Optional, if you initialize it, even with None, it will make Pylance think it's required.
- AN
@joein
- TA
@danielbichuetti Oh, I see
- DA
@andrey.vasnetsov @joein To fix that with Pylance (VS Code), I just got one workaround. Just add before None
default=
. Explicitly doing this will work, and it won't annoy users anymore. - JO
Hi @danielbichuetti, @Tarida George
We've addressed this issue inUpdates will be available with the next package release
- TA
Do you know when the next release is goging to happen?
- AN
apx 2 weeks
Last active a month ago
29 replies
5 views