Skip to content

Instantly share code, notes, and snippets.

@gidgid
Last active October 1, 2020 19:43
Show Gist options
  • Save gidgid/7d8abb5b0fb63a8b29b839949129ba6a to your computer and use it in GitHub Desktop.
Save gidgid/7d8abb5b0fb63a8b29b839949129ba6a to your computer and use it in GitHub Desktop.
Using HttpUrl with validate_arguments
from typing import Optional
from pydantic import validate_arguments, HttpUrl, PositiveInt
@validate_arguments
def better_get_payload(
url: HttpUrl, # 1
retries: PositiveInt
) -> Optional[dict]:
# send the actual request - no need to verify URL # 2
return {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment