Closed smarie closed 3 years ago
This is actually not a bug. typing.Optional
is a misleading term saying that the type is optional (not the value). Therefore, the field can be none (is nonable), but that does not mean that it has a default value.
So this works : City(name=None)
Unfortunately the "Optional" name was not refactored in typing
, and the very interesting discussion on candidate replacement names ended by "it is too late" :) https://github.com/python/typing/issues/452#issuecomment-364919052
Calling the constructor without arguments :
City()
leads toTypeError: __init__() missing 1 required positional argument: 'name'