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

[REQUEST] format requests.structures.CaseInsensitiveDict #3098

Open
nschloe opened this issue Aug 23, 2023 · 2 comments
Open

[REQUEST] format requests.structures.CaseInsensitiveDict #3098

nschloe opened this issue Aug 23, 2023 · 2 comments

Comments

@nschloe
Copy link

nschloe commented Aug 23, 2023

Rich pretty-prints dictionaries, but not yet requests's requests.structures.CaseInsensitiveDict. Given the ubiquity of the package, perhaps it's worthwhile including it.

MWE:

import requests
from rich import print

res = requests.get("https://google.com/")

print(type(res.headers))
print()
print(res.headers)
<class 'requests.structures.CaseInsensitiveDict'>

{'Date': 'Wed, 23 Aug 2023 16:08:49 GMT', 'Expires': '-1', 'Cache-Control': 'private, 
max-age=0', 'Content-Type': 'text/html; charset=ISO-8859-1', 
'Content-Security-Policy-Report-Only': "object-src 'none';base-uri 'self';script-src 
'nonce-Did538OvR0ktCtCDMziyVw' 'strict-dynamic' 'report-sample' 'unsafe-eval' 
'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp", 
'P3P': 'CP="This is not a P3P policy! See g.co/p3phelp for more info."', 
'Content-Encoding': 'gzip', 'Server': 'gws', 'X-XSS-Protection': '0', 
'X-Frame-Options': 'SAMEORIGIN', 'Set-Cookie': 'SOCS=CAAaBgiAmJWnBg; expires=Sat, 
21-Sep-2024 16:08:49 GMT; path=/; domain=.google.com; Secure; SameSite=lax, 
AEC=Ad49MVFl3w4DY94CQi-gf_PVObGt9elybIiZtxypp0YtY72ry6fqk7BabQ; expires=Mon, 
19-Feb-2024 16:08:49 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax, 
__Secure-ENID=14.SE=KWbL5XujSea1jqO5SxWtrQ8ehy_TqnwI3oYhaXpykAA_RoguQQvQTvsrorgGd-A5_h
rdqgz4KknqtKyo_9kMFrTmtKY0BMw9tCcPYRAVc9B9dyp8rafr_Wh4KmqpIY3Y0eVuTNxUGi7gaMUv_LZfvmgL
eJacYTmmz80cb4_d-Cc; expires=Sun, 22-Sep-2024 08:27:07 GMT; path=/; 
domain=.google.com; Secure; HttpOnly; SameSite=lax', 'Alt-Svc': 'h3=":443"; 
ma=2592000,h3-29=":443"; ma=2592000', 'Transfer-Encoding': 'chunked'}
@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

It would probably be easier to add a __rich_repr__ method to the object in requests.

This might give nicer output:

print(dict(res.headers))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants