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

Fix: Httpx Human Readable Responses #788

Merged
merged 7 commits into from
Dec 12, 2023

Conversation

parkerhancock
Copy link
Contributor

Little quality of life upgrade for #784 and httpx support. We fixed a lot of the functional issues by forcing a binary content type on all files regardless of mime type. But that makes the bodies not human readable in the cassettes, which is one of the big advantages of using VCRpy. This fixes it by attempting to convert all response bodies to text using utf-8, and if it fails to do so, then records binary content.

In no circumstance should this optional encoding of response bodies change the actual data coming to or from the client.

Test coverage also included!

@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dd97b02) 90.10% compared to head (bbf1055) 90.13%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #788      +/-   ##
==========================================
+ Coverage   90.10%   90.13%   +0.03%     
==========================================
  Files          27       27              
  Lines        1809     1815       +6     
  Branches      335      336       +1     
==========================================
+ Hits         1630     1636       +6     
  Misses        134      134              
  Partials       45       45              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@jairhenrique jairhenrique left a comment

Choose a reason for hiding this comment

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

LGTM

@jairhenrique
Copy link
Collaborator

@parkerhancock please, rebase with master!

@hartwork hartwork changed the title FIX: Httpx Human Readable Responses Fix: Httpx Human Readable Responses Dec 11, 2023
@jairhenrique
Copy link
Collaborator

@parkerhancock can you fix lint errors!?

@parkerhancock
Copy link
Contributor Author

Hey! Just tried to. Ruff on my computer doesn't show any errors. Not sure what to do here..

@hartwork
Copy link
Collaborator

sure

Hi @parkerhancock, are you running the same version as CI: ruff 0.1.7? It says:

Would reformat: tests/integration/test_httpx.py
Would reformat: vcr/stubs/httpx_stubs.py

(at https:/kevin1024/vcrpy/actions/runs/7183525284/job/19562496307?pr=788#step:5:9).

The other issue looks like a flaky thing and should go away after re-running so ruff is likely our main and only thing to address here.

@hartwork
Copy link
Collaborator

The other issue looks like a flaky thing and should go away after re-running so ruff is likely our main and only thing to address here.

@parkerhancock that just got proven correct be rerunning the CI.

@jairhenrique I'm using pre-commit to run the same checks for local commits and in CI at multiple places and it would be the perfect fit for our use of ruff and make sure everyone is on the same version as a side-effect. Is that a direction that you would support in general? I can make a pull request about it but I'd want to be sure to not waste my time. Here's what I'm using with git-delete-merged-branches for example:

What do you think?

@hartwork
Copy link
Collaborator

hartwork commented Dec 12, 2023

@jairhenrique PS: In any case the CI should invoke ruff in a way where we can see a diff of the changes produced, using git diff --exit-status if we need to, ruff build-in if we can. Not seeing a diff just proves to not be nice to contributors.

@jairhenrique
Copy link
Collaborator

@hartwork personally I don't like pre-commit because it is a tool that can be bypassed with git's --no-verify parameter. It might be useful, but I prefer to just trust the ci result.

We can add ruff parameters that show a diff on errors.

@jairhenrique
Copy link
Collaborator

@parkerhancock i run, ruff format .

@hartwork
Copy link
Collaborator

@hartwork personally I don't like pre-commit because it is a tool that can be bypassed with git's --no-verify parameter. It might be useful, but I prefer to just trust the ci result.

@jairhenrique I think there is a misunderstanding here: the CI still enforces ruff, it just uses pre-commit to do that — command pre-commit run --all-files --show-diff-on-failure — and as a result the local pre-commit hooks and the what the CI enforces always match 100%: --no-verify cannot take that away, it would be as strict as before. This https:/hartwork/git-delete-merged-branches/actions/runs/7172651706/job/19530292191#step:4:129 is where it would read "ruff" instead and where a diff would be shown below also in case of deviation.

@jairhenrique
Copy link
Collaborator

@hartwork feel free to open a pr with pre-commit feature!

About this pr, do you think we can merge?

@hartwork
Copy link
Collaborator

@hartwork feel free to open a pr with pre-commit feature!

@jairhenrique alright, it will take a few minutes, probably before 20:00 UTC+1 though.

About this pr, do you think we can merge?

I haven't looked into httpx integration here at all yet, I would want leave that topic to the two of you for now.

@jairhenrique jairhenrique merged commit 88cf01a into kevin1024:master Dec 12, 2023
10 checks passed
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.

4 participants