ioxiocom / firedantic

Database models for Firestore using Pydantic base models.
BSD 3-Clause "New" or "Revised" License
43 stars 14 forks source link

Warnings about filters using positional arguments #47

Closed joakimnordling closed 6 months ago

joakimnordling commented 10 months ago

When you run the tests you get couple of warnings about filters using positional arguments:

  /Users/xxx/Library/Caches/pypoetry/virtualenvs/firedantic-526ElIO_-py3.9/lib/python3.9/site-packages/google/cloud/firestore_v1/base_collection.py:290: UserWarning: Detected filter using positional arguments. Prefer using the 'filter' keyword argument instead.
    return query.where(field_path, op_string, value)

firedantic/tests/tests_async/test_model.py::test_find
  /Users/xxx/yyy/firedantic/firedantic/_async/model.py:150: UserWarning: Detected filter using positional arguments. Prefer using the 'filter' keyword argument instead.
    query: AsyncQuery = query.where(field, f_type, value[f_type])  # type: ignore

firedantic/tests/tests_sync/test_model.py::test_find
  /Users/xxx/yyy/firedantic/firedantic/_sync/model.py:148: UserWarning: Detected filter using positional arguments. Prefer using the 'filter' keyword argument instead.
    query: BaseQuery = query.where(field, f_type, value[f_type])  # type: ignore
JamesHutchison commented 10 months ago

Coming from here:

    def where(
        self,
        field_path: Optional[str] = None,
        op_string: Optional[str] = None,
        value=None,
        *,
        filter=None,
    ) -> QueryType:
   ...
            return query.where(field_path, op_string, value)  <--- warning is here
        else:
            return query.where(filter=filter)

Looks like they want people to switch to the filter kwarg