Use a custom deprecation warning visible by default#1029
Conversation
Add HTTPXDeprecationWarning, which inherits from UserWarning so it is visible by default, and use it as the category for the deprecated URL.raw property.
|
Docs preview: |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 071ba655e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ] | ||
|
|
||
|
|
||
| class HTTPXDeprecationWarning(UserWarning): |
There was a problem hiding this comment.
Export the new deprecation warning category
Please add this warning class to the public exports as well. httpx2.__init__ re-exports exceptions via from ._exceptions import *, which is limited by _exceptions.__all__; since HTTPXDeprecationWarning is omitted there (and from the top-level __all__), users who see the new URL.raw warning cannot write a public filter such as warnings.filterwarnings(..., category=httpx2.HTTPXDeprecationWarning) and must either suppress all UserWarnings or import from the private httpx2._exceptions module.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/httpx2/httpx2/_exceptions.py">
<violation number="1" location="src/httpx2/httpx2/_exceptions.py:74">
P1: `HTTPXDeprecationWarning` is missing from both `_exceptions.py`'s `__all__` and `__init__.py`'s re-exports — users cannot import it from `httpx2` or via star-import</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ] | ||
|
|
||
|
|
||
| class HTTPXDeprecationWarning(UserWarning): |
There was a problem hiding this comment.
P1: HTTPXDeprecationWarning is missing from both _exceptions.py's __all__ and __init__.py's re-exports — users cannot import it from httpx2 or via star-import
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/httpx2/httpx2/_exceptions.py, line 74:
<comment>`HTTPXDeprecationWarning` is missing from both `_exceptions.py`'s `__all__` and `__init__.py`'s re-exports — users cannot import it from `httpx2` or via star-import</comment>
<file context>
@@ -71,6 +71,16 @@
]
+class HTTPXDeprecationWarning(UserWarning):
+ """A custom deprecation warning for HTTPX.
+
</file context>
Add
HTTPXDeprecationWarning, which inherits fromUserWarninginstead ofDeprecationWarningso it is visible by default - helping users discover deprecated features without enabling warnings explicitly. It's used as thecategoryfor the deprecatedURL.rawproperty.Analogous to Starlette's
StarletteDeprecationWarning. Reference: https://sethmlarson.dev/deprecations-via-warnings-dont-work-for-python-librariesAI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.