The Fix
pip install urllib3==2.2.2
Based on closed urllib3/urllib3 issue #3363 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+Consistently used ``typing.Self`` for return types representing copying actions.
diff --git a/src/urllib3/_collections.py b/src/urllib3/_collections.py
index 55b0324797..8a4409a122 100644
from typing import Any, Self
import urllib3
class MyRetry(urllib3.Retry):
def increment(self, *a: Any, **k: Any) -> Self: # type error on this line!
return super().increment(*a, **k)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install urllib3==2.2.2\nWhen NOT to use: This fix should not be used if backward compatibility with older Python versions is required.\n\n
Why This Fix Works in Production
- Trigger: t.py:5: error: Incompatible return value type (got "Retry", expected "Self") [return-value]
- Mechanism: Resolves issue #3363 by using `Self` from `typing_extensions` for return types in the `urllib3.Retry` class methods.
- Why the fix works: Resolves issue #3363 by using `Self` from `typing_extensions` for return types in the `urllib3.Retry` class methods. (first fixed release: 2.2.2).
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Triggered by an upgrade/regression window: 3.11 breaks; 2.2.2 is the first fixed release.
- Shows up under Python 3.11 in real deployments (not just unit tests).
- Production symptom (often without a traceback): def increment(self, *a: Any, **k: Any) -> Self: # type error on this line!
Proof / Evidence
- GitHub issue: #3363
- Fix PR: https://github.com/urllib3/urllib3/pull/3364
- First fixed release: 2.2.2
- Affected versions: 3.11
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.64
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Thanks for reporting this! > if the codebase were python 3.11+ I would use from typing import Self -- it appears elsewhere in the codebase…”
Failure Signature (Search String)
- t.py:5: error: Incompatible return value type (got "Retry", expected "Self") [return-value]
Copy-friendly signature
Failure Signature
-----------------
def increment(self, *a: Any, **k: Any) -> Self: # type error on this line!
t.py:5: error: Incompatible return value type (got "Retry", expected "Self") [return-value]
Error Message
Signature-only (no traceback captured)
Error Message
-------------
def increment(self, *a: Any, **k: Any) -> Self: # type error on this line!
t.py:5: error: Incompatible return value type (got "Retry", expected "Self") [return-value]
Minimal Reproduction
from typing import Any, Self
import urllib3
class MyRetry(urllib3.Retry):
def increment(self, *a: Any, **k: Any) -> Self: # type error on this line!
return super().increment(*a, **k)
Environment
- Python: 3.11
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==2.2.2
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/urllib3/urllib3/pull/3364
First fixed release: 2.2.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if backward compatibility with older Python versions is required.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 3.11 | Broken |
| 2.2.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.