Skip to content

Feature: support sequence and mapping input #176

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

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

mjpieters
Copy link
Contributor

  • Most dict parameters can be any mapping type
  • Most list parameters can be any iterable, or if stored, any sequence

These changes make it a lot easier to use, say, TypedDict to define GraphQL query input values.

Also see the Arguments and Return Types section in the Typing Best Practices chapter of the Python static typing documentation.

Mapping[str, str],
Mapping[bytes, bytes],
Sequence[tuple[str, str]],
Sequence[tuple[bytes, bytes]],
]

CookieTypes: TypeAlias = Union[httpx.Cookies, dict[str, str], list[tuple[str, str]]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: The httpx methods that accept CookieTypes define these as dict and list too, so these can't be broadened.

@yanyongyu yanyongyu added the enhancement New feature or request label Jan 7, 2025
@yanyongyu
Copy link
Owner

Thanks for your PR 👍🏻 . I may need to spend some time reviewing all the changes.

@yanyongyu yanyongyu changed the title Be more accepting of input types Feature: support sequence and mapping input Jan 8, 2025
@mjpieters mjpieters force-pushed the widen_accepted_types branch from a3c57f7 to 0e552b4 Compare January 9, 2025 15:37
- Most `dict` parameters can be any mapping type
- Most `list` parameters can be any iterable, or if stored, any sequence
@mjpieters mjpieters force-pushed the widen_accepted_types branch from 0e552b4 to 8bdc1d4 Compare January 9, 2025 15:46
@mjpieters mjpieters requested a review from yanyongyu January 9, 2025 16:38
@yanyongyu yanyongyu merged commit 2268d93 into yanyongyu:master Jan 10, 2025
32 checks passed
@mjpieters mjpieters deleted the widen_accepted_types branch January 10, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy