typing: property/setter and lists? [RESOLVED]
Paulo da Silva
p_d_a_s_i_l_v_a_ns at nonetnoaddress.pt
Thu Nov 3 14:37:43 EDT 2022
Às 18:16 de 03/11/22, Chris Angelico escreveu:
> On Fri, 4 Nov 2022 at 05:03, Paulo da Silva
> <p_d_a_s_i_l_v_a_ns at nonetnoaddress.pt> wrote:
>> Changing def foos(self) -> list[int]: to
>> def foos(self) -> Union[list[int]]:
>> fixes the problem.
>> Not so elegant, however!
>
> Wait, what?!
>
> Union[X, Y] means "X or Y"
> Union[X] means "X, but don't complain if it's a @property".
>
> Is that how it goes?
I'm sorry. A bad transposition of the text. I meant
def foos(self) -> Union[list[int],int]:
Regards.
Paulo
More information about the Python-list
mailing list