Skip to content

fix: deprecate python 3.9 in all packages - #1365

Merged
o-santi merged 7 commits into
mainfrom
deprecate-python-3-9
Feb 3, 2026
Merged

o-santi merged 7 commits into
mainfrom
deprecate-python-3-9

Conversation

@o-santi

@o-santi o-santi commented Feb 2, 2026 •

Copy link
Copy Markdown
Contributor

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

  • New Features
    • Requests now include richer client and environment metadata via new X-... headers (client/version, OS, Python runtime).
  • Deprecations
    • Python 3.9 is being phased out; running Python < 3.10 will emit deprecation warnings.
  • Bug Fixes
    • Authorization header is now synchronized consistently across client components on auth events.
  • Tests
    • Tests updated to expect the new client-identifying header format.

also add python version in user header, so that we can track how many
users are still using it.
@coderabbitai

coderabbitai Bot commented Feb 2, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Auth — header refactor & constants removal
src/auth/src/supabase_auth/_async/gotrue_client.py, src/auth/src/supabase_auth/_sync/gotrue_client.py, src/auth/src/supabase_auth/constants.py
Removes DEFAULT_HEADERS from constants; GoTrue clients now build X-Client-Info and X-Supabase-Client-* headers (platform/runtime/version), merge provided headers, and emit a Python < 3.10 DeprecationWarning.
Functions — headers & deprecation
src/functions/src/supabase_functions/_async/functions_client.py, src/functions/src/supabase_functions/_sync/functions_client.py
Replaces User-Agent with X-Client-Info and adds X-Supabase-Client-Platform, -Platform-Version, -Runtime, -Runtime-Version; imports platform/sys; emits DeprecationWarning for Python < 3.10; preserves existing timeout/verify/proxy warnings.
Postgrest — headers & deprecation
src/postgrest/src/postgrest/_async/client.py, src/postgrest/src/postgrest/_sync/client.py
Client initializers now set X-Client-Info and platform/runtime metadata, import platform/sys, and warn on Python < 3.10 during initialization.
Storage — headers & deprecation
src/storage/src/storage3/_async/client.py, src/storage/src/storage3/_sync/client.py
Replaces User-Agent with X-Client-Info plus runtime/OS headers, adds platform/sys imports, and emits a DeprecationWarning for Python < 3.10.
Realtime — deprecation check
src/realtime/src/realtime/_async/client.py
Adds a Python < 3.10 DeprecationWarning check in the async Realtime client initializer; no header changes.
Supabase client — auth header sync
src/supabase/src/supabase/_async/client.py, src/supabase/src/supabase/_sync/client.py
When listening to auth events, computes auth_header once and assigns it to both self.options.headers["Authorization"] and self.auth._headers["Authorization"] to keep headers synchronized.
Tests — updated header expectations
src/functions/tests/_async/test_function_client.py, src/functions/tests/_sync/test_function_client.py
Updated test assertions to expect X-Client-Info (supabase-py/supabase_functions v{__version__}) instead of User-Agent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: deprecate python 3.9 in all packages' accurately describes the primary change: adding deprecation warnings for Python 3.9 across all client packages.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch deprecate-python-3-9

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@o-santi
o-santi requested a review from a team February 2, 2026 20:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Missing 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 | 🟡 Minor

Missing 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,
             )

@o-santi o-santi changed the title fix: deprecate python 3.9 in all versions fix: deprecate python 3.9 in all packages Feb 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@coveralls

coveralls commented Feb 3, 2026 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21634739967

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 325 unchanged lines in 9 files lost coverage.
  • Overall coverage increased (+0.02%) to 91.166%

Files with Coverage Reduction New Missed Lines %
src/supabase_functions/_sync/functions_client.py 2 97.22%
src/supabase_functions/_async/functions_client.py 2 97.22%
src/postgrest/_sync/client.py 3 94.0%
src/postgrest/_async/client.py 3 94.0%
src/storage3/_async/client.py 5 87.5%
src/storage3/_sync/client.py 5 87.5%
src/realtime/_async/client.py 46 72.14%
src/supabase_auth/_async/gotrue_client.py 127 73.93%
src/supabase_auth/_sync/gotrue_client.py 132 73.07%
Totals Coverage Status
Change from base Build 21405510096: 0.02%
Covered Lines: 8999
Relevant Lines: 9871

💛 - Coveralls

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +126 to +131
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,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
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.

@supabase supabase deleted a comment from coderabbitai Bot Feb 3, 2026
coderabbitai Bot added a commit that referenced this pull request Feb 3, 2026
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`
@coderabbitai

coderabbitai Bot commented Feb 3, 2026

Copy link
Copy Markdown

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #1366

@o-santi
o-santi merged commit cc72ed7 into main Feb 3, 2026
94 of 119 checks passed
@o-santi
o-santi deleted the deprecate-python-3-9 branch February 3, 2026 15:54
@coderabbitai coderabbitai Bot mentioned this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants