Repository navigation
fix: deprecate python 3.9 in all packages - #1365
Conversation
also add python version in user header, so that we can track how many users are still using it.
📝 WalkthroughWalkthroughAdds per-client HTTP headers with SDK and runtime metadata across multiple clients, removes centralized DEFAULT_HEADERS from auth constants, and emits DeprecationWarning for Python < 3.10 during several client initializations. Also syncs Authorization header into internal auth client on auth events. No public signatures changed. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/auth/src/supabase_auth/_async/gotrue_client.py (1)
114-128:⚠️ Potential issue | 🟡 MinorMissing Python 3.9 deprecation warning for consistency.
The PR objective states "Adds a deprecation warning when running on Python 3.9 that is emitted when creating one of the package clients." However, this auth client is missing the deprecation warning that is present in all other clients (functions, postgrest, storage, realtime).
Consider adding the warning after the header construction for consistency:
🔧 Proposed fix to add deprecation warning
extra_headers = { "User-Agent": f"supabase-py/supabase_auth v{__version__}", "X-Python-Version": sys.version, "X-OS": sys.platform, } if headers: extra_headers.update(headers) + + if sys.version_info < (3, 10): + from warnings import warn + warn( + "Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version", + DeprecationWarning, + stacklevel=2, + ) + AsyncGoTrueBaseAPI.__init__(src/auth/src/supabase_auth/_sync/gotrue_client.py (1)
114-128:⚠️ Potential issue | 🟡 MinorMissing Python 3.9 deprecation warning for consistency.
Same as the async version, the sync GoTrue client is missing the Python 3.9 deprecation warning that other clients include. This creates an inconsistency where users of only the auth module won't be warned about Python 3.9 deprecation.
🔧 Proposed fix to add deprecation warning
+from warnings import warn + # ... in __init__ after header construction ... + + if sys.version_info < (3, 10): + warn( + "Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version", + DeprecationWarning, + stacklevel=2, + )
🤖 Fix all issues with AI agents
In `@src/postgrest/src/postgrest/_async/client.py`:
- Around line 39-44: The User-Agent header in the headers dict incorrectly uses
"functions-py" instead of the postgrest client identifier; update the User-Agent
value constructed in the headers dict (the line building "User-Agent":
f"supabase-py/functions-py v{__version__}") to use the correct identifier
"postgrest-py" so it reads "supabase-py/postgrest-py v{__version__}" (leave
__version__ unchanged) in the module where headers is defined.
- Around line 39-44: The User-Agent header is wrong in the postgrest clients;
update the headers dict in both postgrest/_async/client.py and
postgrest/_sync/client.py where headers is constructed (the dict containing
"User-Agent", "X-Python-Version", "X-OS", **headers) to use
"supabase-py/postgrest v{__version__}" instead of "supabase-py/functions-py
v{__version__}"; locate the headers dict in the client constructors (references:
the variable name headers and the module-level __version__) and change the
string accordingly in both files.
In `@src/postgrest/src/postgrest/_sync/client.py`:
- Around line 39-44: The User-Agent in the headers dict inside
postgrest/_sync/client.py is a copy-paste from the functions client and
incorrectly reads "supabase-py/functions-py"; update the f-string used to build
the "User-Agent" value to identify this client as postgrest (e.g.,
"supabase-py/postgrest-py v{__version__}") so server-side analytics attribute
requests to the correct client; modify the headers assignment where "User-Agent"
is set (referencing the headers dict and __version__) to use the corrected
identifier.
🧹 Nitpick comments (2)
src/storage/src/storage3/_sync/client.py (1)
42-47: Minor: Warning message may be misleading for Python versions below 3.9.The condition
sys.version_info < (3, 10)triggers for Python 3.8, 3.7, etc., but the message specifically states "Python 3.9 has reached EOL". Consider a more generic message:Suggested improvement
if sys.version_info < (3, 10): warn( - "Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version", + "Python versions below 3.10 are deprecated and will not be supported in future versions. Please upgrade to Python 3.10 or newer.", DeprecationWarning, stacklevel=2, )src/postgrest/src/postgrest/_async/client.py (1)
46-51: Same suggestion as storage client: consider a more generic deprecation message.The message specifically mentions "Python 3.9" but the condition catches all versions below 3.10.
Suggested improvement
if sys.version_info < (3, 10): warn( - "Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version", + "Python versions below 3.10 are deprecated and will not be supported in future versions. Please upgrade to Python 3.10 or newer.", DeprecationWarning, stacklevel=2, )
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/auth/src/supabase_auth/_sync/gotrue_client.py`:
- Around line 116-124: The header key in gotrue_client.py's extra_headers uses
"User-Agent" while Storage and Functions use "X-Client-Info"; update the code in
the extra_headers initialization inside the Gotrue client (look for
extra_headers and __version__ in gotrue_client.py) to use the same
"X-Client-Info" format (e.g., "X-Client-Info": f"supabase-py/supabase_auth
v{__version__}") OR, if GoTrue intentionally requires "User-Agent", add a brief
inline comment above the extra_headers block explaining the reason for the
divergence and referencing the Storage/Functions clients for clarity so future
readers know this is intentional.
Pull Request Test Coverage Report for Build 21634739967Details
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/auth/src/supabase_auth/_async/gotrue_client.py`:
- Around line 126-131: The deprecation warning checks for any Python < 3.10 but
the message explicitly mentions "Python 3.9"; change the condition to target
only Python 3.9 so it's accurate: update the version check that currently uses
sys.version_info < (3, 10) to a precise check for Python 3.9 (e.g., inspect
sys.version_info[:2] == (3, 9)) and keep the existing warn(...) call and message
intact so only 3.9 triggers the DeprecationWarning.
| if sys.version_info < (3, 10): | ||
| warn( | ||
| "Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) |
There was a problem hiding this comment.
Align the warning condition with the message.
Line 126 triggers for any Python < 3.10, but the message says “Python 3.9 has reached EOL”. On 3.8, this is misleading. Either narrow the check to 3.9 or widen the message.
✅ Suggested fix (narrow to 3.9 only)
- if sys.version_info < (3, 10):
+ if (3, 9) <= sys.version_info < (3, 10):
warn(
"Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version",
DeprecationWarning,
stacklevel=2,
)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if sys.version_info < (3, 10): | |
| warn( | |
| "Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version", | |
| DeprecationWarning, | |
| stacklevel=2, | |
| ) | |
| if (3, 9) <= sys.version_info < (3, 10): | |
| warn( | |
| "Python 3.9 has reached EOL, and is not going to be supported in future versions. Please, upgrade to a newer python version", | |
| DeprecationWarning, | |
| stacklevel=2, | |
| ) |
🤖 Prompt for AI Agents
In `@src/auth/src/supabase_auth/_async/gotrue_client.py` around lines 126 - 131,
The deprecation warning checks for any Python < 3.10 but the message explicitly
mentions "Python 3.9"; change the condition to target only Python 3.9 so it's
accurate: update the version check that currently uses sys.version_info < (3,
10) to a precise check for Python 3.9 (e.g., inspect sys.version_info[:2] == (3,
9)) and keep the existing warn(...) call and message intact so only 3.9 triggers
the DeprecationWarning.
Docstrings generation was requested by @o-santi. * #1365 (comment) The following files were modified: * `src/auth/src/supabase_auth/_async/gotrue_client.py` * `src/auth/src/supabase_auth/_sync/gotrue_client.py` * `src/functions/src/supabase_functions/_async/functions_client.py` * `src/functions/src/supabase_functions/_sync/functions_client.py` * `src/postgrest/src/postgrest/_async/client.py` * `src/postgrest/src/postgrest/_sync/client.py` * `src/realtime/src/realtime/_async/client.py` * `src/storage/src/storage3/_async/client.py` * `src/storage/src/storage3/_sync/client.py` * `src/supabase/src/supabase/_async/client.py` * `src/supabase/src/supabase/_sync/client.py`
|
Note Docstrings generation - SUCCESS |
What kind of change does this PR introduce?
Adds a deprecation warning on python 3.9 when creating one of the packages' client. Also adds python version and OS in user header, so that we can track how many users are still using it.
Summary by CodeRabbit