Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use async/await in the readme example #383

Merged
merged 3 commits into from
May 1, 2024
Merged

Use async/await in the readme example #383

merged 3 commits into from
May 1, 2024

Conversation

twm
Copy link
Contributor

@twm twm commented Apr 30, 2024

Fixes #382.

Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

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

Thanks for the update.

Only a minor comments about the links in the README

I think that treq is an important library.
I would love to have it integrated in twisted/twisted

|calver|_
|coverage|_
|documentation|_
|pypi|
Copy link
Member

Choose a reason for hiding this comment

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

I think that this is needed...as otherwise the links are not working

I was testing with https://github.com/twisted/treq/tree/382-async-await-readme?tab=readme-ov-file

see as a playground https://rsted.info.ucl.ac.be/?theme=basic&n=8fd54317743434ab9a96c339c7862241

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I was trying to get rid of the underscores GitHub shows on current trunk:

image

But actually, the links there don't work either. I'll see if I can get that working — I'm a bit rusty on reST.

Copy link
Member

Choose a reason for hiding this comment

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

It looks like a bug in GitHub... I see the same problem with twisted/twisted

For twisted/towncrier we don't use the substitution ... maybe update treq to just use the image directive

.. image:: https://img.shields.io/pypi/v/towncrier
   :alt: PyPI release
   :target: https://pypi.org/project/towncrier/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The substitution seems to work, the key is to make it a link with :target: as you suggested. I guess the link targets .. _calver: were picked up implicitly by docutils? Or maybe this never worked.

@twm
Copy link
Contributor Author

twm commented May 1, 2024

Thank you for the review @adiroiban!

I would love to have it integrated in twisted/twisted

There are certainly parts of it that could live in twisted/twisted:

  • RequestTraversalAgent (I've often taken a treq dep just for this)
  • The body helpers in treq.content
  • A better version of treq.auth
  • MultiPartProducer (if its bugs were fixed)

Some parts that are iffy:

  • HTTPClient
    • the interface is large, which makes it annoying to wrap (contrast with Agent)
    • all the methods here have heavily-overloaded arguments which is a very different style from Twisted proper (and parameter types are nearly incomprehensible because of that overloading)

ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn

  • The "augmented" _Response type duplicates treq.content API surface and also buffers the response by default

Finally there some parts that I'd never put in twisted/twisted:

  • Functions with global state (treq.request(), treq.get(), etc.)
  • The requests dependency
  • Treating header values as UTF-8 is simply wrong
  • StubTreq (this should be a helper function that returns an appropriately-configured HTTPClient)

@twm
Copy link
Contributor Author

twm commented May 1, 2024

Thanks again Adi!

@twm twm merged commit eb301b5 into trunk May 1, 2024
16 checks passed
@twm twm deleted the 382-async-await-readme branch May 1, 2024 21:25
@adiroiban
Copy link
Member

Thanks for the info related to having treq code in twisted/twisted

I think merging parts of treq into twisted/twisted is a better approach.

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.

Readme example should use async/await
2 participants