Skip to content

Fix treq.request() argument handling#431

Merged
twm merged 11 commits into
trunkfrom
treq-401-followups
Jul 1, 2026
Merged

Fix treq.request() argument handling#431
twm merged 11 commits into
trunkfrom
treq-401-followups

Conversation

@twm

@twm twm commented Jun 6, 2026

Copy link
Copy Markdown
Member

Following up on #401, this fixes some bugs in the parameter handling of treq.request(). This addresses that hole in the test suite.

I still need to:

I'm putting this PR up now just to be clear that we're not ready to release.

@twm twm marked this pull request as ready for review June 19, 2026 07:50
@twm twm requested a review from a team June 19, 2026 07:50

@adiroiban adiroiban left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. Thanks!

Only very minor comments.

Comment thread src/treq/_types.py
_S = Union[bytes, str]

_URLType = Union[
_SomeURL = Union[

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe call it _TreqURL ... some seems strange to me

Comment thread src/treq/test/test_api.py Outdated
Comment on lines +111 to +118
for func in (
treq.head,
treq.get,
treq.post,
treq.put,
treq.patch,
treq.delete,
):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe also assert the HTTP method used for each function

Suggested change
for func in (
treq.head,
treq.get,
treq.post,
treq.put,
treq.patch,
treq.delete,
):
for func, method in (
(treq.head, 'HEAD'),
(treq.get, 'GET'),
(treq.post, 'POST'),
(treq.put, 'PUT'),
(treq.patch, 'PATCH'),
(treq.delete, 'DELETE'),
):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good idea!

Comment thread src/treq/test/test_api.py Outdated
self.requests += 1
return defer.Deferred()
self.assertNoResult(d)
self.assertEqual(1, counter_agent.requests)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure if the CounterAgent is good enough...
I was thinking to make sure that each function is associated

Suggested change
self.assertEqual(1, counter_agent.requests)
self.assertEqual([(method, "https://www.example.org/")], counter_agent.requests)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds like a job for agent_spy()!

Comment thread src/treq/test/test_api.py
Comment thread src/treq/test/test_api.py

@twm twm left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you for the review @adiroiban!

@twm twm merged commit 85b8f7e into trunk Jul 1, 2026
17 checks passed
@twm twm deleted the treq-401-followups branch July 1, 2026 22:05
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.

2 participants