File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,25 @@ return type by using overloads like so:
295
295
subtypes, you can use a :ref: `value restriction
296
296
<type-variable-value-restriction>`.
297
297
298
+ The default values of a function's arguments don't affect its signature, only
299
+ the absence or presence of a default value does. So in order to reduce
300
+ redundancy it's possible to replace default values in overload definitions with
301
+ `... ` as a placeholder.
302
+
303
+ .. code-block :: python
304
+
305
+ from typing import overload
306
+
307
+ class M : ...
308
+
309
+ @overload
310
+ def get_model (model_or_pk : M, flag : bool = ... ) -> M: ...
311
+ @overload
312
+ def get_model (model_or_pk : int , flag : bool = ... ) -> M | None : ...
313
+
314
+ def get_model (model_or_pk : int | M, flag : bool = True ) -> M | None :
315
+ ...
316
+
298
317
299
318
Runtime behavior
300
319
----------------
You can’t perform that action at this time.
0 commit comments