Hey there fellows!
I have a query, about the correct way to annotate my function. Thanks ahead for the help. I tried doing like ‘genreral_func() -> str | dict | None’ But then ‘def return_hosts() -> str | None’ Return the following mypy error: ‘expected str | dict | None but recived str| None’
”’ def general_func(func_a, func_b, func_c, type, kwargs) –> ??? If “ilo” in **kwargs: return func_b(kwargs) If “cinc” in kwargs: return func_a(kwargs) if “idrac” in kwargs: return func_c(kwargs)
def return_host(server) -> str | None: return general_func(cimc.gethost, ilo.gethost, idrac.gethost, server=server)
def return_nics(server)-> dict| str: return general_func(cimc.nics,, ilo.nics, idrac.nics, server=server) ”’
Sorry I don’t know how to make the text code-like in my phone.
submitted by /u/LoliPopeye
[link] [comments]
r/learnpython Hey there fellows! I have a query, about the correct way to annotate my function. Thanks ahead for the help. I tried doing like ‘genreral_func() -> str | dict | None’ But then ‘def return_hosts() -> str | None’ Return the following mypy error: ‘expected str | dict | None but recived str| None’ ”’ def general_func(func_a, func_b, func_c, type, kwargs) –> ??? If “ilo” in **kwargs: return func_b(kwargs) If “cinc” in kwargs: return func_a(kwargs) if “idrac” in kwargs: return func_c(kwargs) def return_host(server) -> str | None: return general_func(cimc.gethost, ilo.gethost, idrac.gethost, server=server) def return_nics(server)-> dict| str: return general_func(cimc.nics,, ilo.nics, idrac.nics, server=server) ”’ Sorry I don’t know how to make the text code-like in my phone. submitted by /u/LoliPopeye [link] [comments]
Hey there fellows!
I have a query, about the correct way to annotate my function. Thanks ahead for the help. I tried doing like ‘genreral_func() -> str | dict | None’ But then ‘def return_hosts() -> str | None’ Return the following mypy error: ‘expected str | dict | None but recived str| None’
”’ def general_func(func_a, func_b, func_c, type, kwargs) –> ??? If “ilo” in **kwargs: return func_b(kwargs) If “cinc” in kwargs: return func_a(kwargs) if “idrac” in kwargs: return func_c(kwargs)
def return_host(server) -> str | None: return general_func(cimc.gethost, ilo.gethost, idrac.gethost, server=server)
def return_nics(server)-> dict| str: return general_func(cimc.nics,, ilo.nics, idrac.nics, server=server) ”’
Sorry I don’t know how to make the text code-like in my phone.
submitted by /u/LoliPopeye
[link] [comments]