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

Regulate top-level arrays #1292

Merged
merged 2 commits into from Feb 8, 2022
Merged

Conversation

isidentical
Copy link
Contributor

@isidentical isidentical commented Feb 3, 2022

Starting with the initial implementation (and later with the second one), we had a special/hidden feature called 'top-level arrays':

$ http --offline --print=B pie.dev/post []:=1 []:=2 []:=3

[
    1,
    2,
    3
]

This is a powerful syntax, since there weren't a way of creating/sending arrays in the past (without sending them as raw data). One thing that we skipped between two different implementations was to make this more stricter.

@ducaale previously started a discussion but we did not made a resolution back then due to worries over this would block the empty-key usage. Now that those are answered in #1286, I think we should be able to make the handling of top-level lists more seriously.

New handling

  • This patch forbids the usage of key-paths without a preceding key [foo]=bar (and variants of this)
  • If you need to embed such a structure, you can still continue to use :={"foo": "bar"}.
  • Mixing top-level list usage with other keys is now forbidden. E.g:
$ http --offline --print=B pie.dev/post a:=1 []:=2
{
    "": [
        2
    ],
    "a": 1
}

@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2022

Codecov Report

Merging #1292 (5d39576) into master (4d7d6b6) will decrease coverage by 0.76%.
The diff coverage is 95.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1292      +/-   ##
==========================================
- Coverage   97.28%   96.52%   -0.77%     
==========================================
  Files          67       85      +18     
  Lines        4235     6012    +1777     
==========================================
+ Hits         4120     5803    +1683     
- Misses        115      209      +94     
Impacted Files Coverage Δ
tests/test_binary.py 100.00% <ø> (ø)
httpie/compat.py 31.11% <27.90%> (-68.89%) ⬇️
tests/conftest.py 77.14% <58.33%> (-9.82%) ⬇️
httpie/output/lexers/http.py 59.09% <59.09%> (ø)
tests/test_ssl.py 91.01% <66.66%> (-3.93%) ⬇️
httpie/manager/__main__.py 82.35% <82.35%> (ø)
httpie/output/lexers/metadata.py 82.35% <82.35%> (ø)
httpie/models.py 94.23% <90.00%> (-3.14%) ⬇️
tests/test_uploads.py 97.70% <92.59%> (-2.30%) ⬇️
httpie/manager/core.py 92.85% <92.85%> (ø)
... and 71 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d45f413...5d39576. Read the comment docs.

@httpie httpie deleted a comment from Breezes1984 Feb 4, 2022
@isidentical isidentical marked this pull request as ready for review February 4, 2022 09:13
@jkbrzt jkbrzt merged commit 225dccb into httpie:master Feb 8, 2022
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.

None yet

3 participants