Hey there! I have a weird question but Im stuck for days on this.
I have quite a lot of requests done via python using the requests module.
def url_requester(url: str) -> list | ???: response=requests.request(method, payload, url, etc) if method==”get”: return response.json()[0] return response.json()
Is there a proper way you type hint this function? It has being killing me, mypy says it is wrong . Thanks!
submitted by /u/LoliPopeye
[link] [comments]
r/learnpython Hey there! I have a weird question but Im stuck for days on this. I have quite a lot of requests done via python using the requests module. def url_requester(url: str) -> list | ???: response=requests.request(method, payload, url, etc) if method==”get”: return response.json()[0] return response.json() Is there a proper way you type hint this function? It has being killing me, mypy says it is wrong . Thanks! submitted by /u/LoliPopeye [link] [comments]
Hey there! I have a weird question but Im stuck for days on this.
I have quite a lot of requests done via python using the requests module.
def url_requester(url: str) -> list | ???: response=requests.request(method, payload, url, etc) if method==”get”: return response.json()[0] return response.json()
Is there a proper way you type hint this function? It has being killing me, mypy says it is wrong . Thanks!
submitted by /u/LoliPopeye
[link] [comments]