Skip to content

Use a custom deprecation warning visible by default#1029

Merged
Kludex merged 4 commits into
mainfrom
custom-deprecation-warning
Jun 11, 2026
Merged

Use a custom deprecation warning visible by default#1029
Kludex merged 4 commits into
mainfrom
custom-deprecation-warning

Conversation

@Kludex

@Kludex Kludex commented Jun 11, 2026

Copy link
Copy Markdown
Member

Add HTTPXDeprecationWarning, which inherits from UserWarning instead of DeprecationWarning so it is visible by default - helping users discover deprecated features without enabling warnings explicitly. It's used as the category for the deprecated URL.raw property.

Analogous to Starlette's StarletteDeprecationWarning. Reference: https://sethmlarson.dev/deprecations-via-warnings-dont-work-for-python-libraries

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

Add HTTPXDeprecationWarning, which inherits from UserWarning so it is
visible by default, and use it as the category for the deprecated
URL.raw property.
@github-actions

Copy link
Copy Markdown

Docs preview:

Comment thread src/httpx2/pyproject.toml Outdated
@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 15 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing custom-deprecation-warning (17f66d4) with main (2dc6324)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Kludex Kludex enabled auto-merge (squash) June 11, 2026 05:52

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@cubic-dev-ai cubic-dev-ai 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.

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):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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>

@Kludex Kludex merged commit 7efe56f into main Jun 11, 2026
15 checks passed
@Kludex Kludex deleted the custom-deprecation-warning branch June 11, 2026 06:18
@Kludex Kludex mentioned this pull request Jun 11, 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.

1 participant