-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
the current typing assumes that
defaultis the same type as the "internal type" returned by the parser method. forurl, that's aurllib.parse.ParseResult.therefore, to pass type-checking, you'd need to do:
from typing import reveal_type from urllib.parse import urlparse from environs import env MY_API_URL = env.url( "MY_API_URL", default=urlparse("http://api.example.com"), ) print(reveal_type(MY_API_URL)) # Runtime type is 'ParseResult'If you want a string, you can use
env.strwith the URL validator.from typing import reveal_type from environs import env, validate MY_API_URL = env.str( "MY_API_URL", default="http://api.example.com", validate=validate.URL(), ) print(reveal_type(MY_API_URL)) # Runtime type is 'str'i've updated the docs to clarify this.
so while the current behavior is expected, perhaps it isn't desired. should
env.urljust return a string and do validation? i'm not sure how many users want aParseResult🤔 . i'll open a new issue for this to gather feedback.