supabase-community / postgrest-py

PostgREST client for Python. This library provides an ORM interface to PostgREST

Home Page:https://postgrest-py.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Will mostly fail on Python 3.11 (string enums no longer literal strings)

SinaKhalili opened this issue · comments

Bug report

Any filter (such as eq, lte, etc) will fail on Python 3.11

To observe this, install python 3.11 and run the existing test suit.

Describe the bug

The pattern for inheriting from (str, Enum) in order to get a literal string (used in types) no longer works in python 3.11.

Instead it's advised to inherit from the standard library's new StrEnum class.

For older versions a check can be done and use the StrEnum package for 3.6+ (not part of standard library).

Alternatively, one could use the .value of an enum and no longer inherit from str.

I can open a PR if you'd like, let me know which approach works best.

Not sure if this is related, but I get json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) on every successful request (get, upsert, delete, etc.) using Python 3.11.

For me it fails on "insert" because the parameter returning is set to ReturnMethod.representation. If i manually set it to "representation" it works.

Hey @SinaKhalili,

Thanks for opening this issue and apologies for the delayed reply - if you still have the bandwidth feel free to open a PR which makes use of StrEnum but no worries if you're occupied. If you could add python3.11 to the CI while you're at it that would be fantastic as well.

Otherwise, we'll get to it when we have a free cycle.

Thanks!