Skip to content

[documentation/typing request] what are allowed values for compress? #10549

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

Open
bddap opened this issue Mar 14, 2025 · 2 comments
Open

[documentation/typing request] what are allowed values for compress? #10549

bddap opened this issue Mar 14, 2025 · 2 comments

Comments

@bddap
Copy link

bddap commented Mar 14, 2025

The compress parameter currently has type Union[str, bool]. It’s clear that False and True are valid, but the documentation doesn’t specify which string values are acceptable.

  • "gzip" appears to work and properly switches the request from deflate to gzip.
  • "some rando string" doesn’t raise an exception, which is unexpected.
  • The docs don’t mention passing a string at all (and they have a small grammar issue too). The docs also seem out of date regarding None, which no longer appears to be valid in the current main branch.

It would be great to:

  1. Use something like typing.Literal["gzip", ...] in place of str, so users know which strings are valid.
  2. Outline these allowed string values in the client documentation.

Appreciate the python package btw. It has been useful.

@Dreamsorcerer
Copy link
Member

As far as I can see in the code, it just sets the mode for zlib:

def encoding_to_mode(
encoding: Optional[str] = None,
suppress_deflate_header: bool = False,
) -> int:
if encoding == "gzip":
return 16 + zlib.MAX_WBITS
return -zlib.MAX_WBITS if suppress_deflate_header else zlib.MAX_WBITS

In which case, yes it's just gzip, deflate/True or False.

@Dreamsorcerer
Copy link
Member

I'm not really familiar with the reason it's designed like that though, so maybe someone else has some idea of whether it might be expanded in future or something..

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

No branches or pull requests

2 participants