File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -676,3 +676,26 @@ Example:
676676 print (" red" )
677677 case _:
678678 print (" other" )
679+
680+ .. _code-untyped-decorator :
681+
682+ Error if an untyped decorator makes a typed function effectively untyped [untyped-decorator]
683+ ----------------------------------------------------->
684+
685+ If enabled with :option: `--disallow-untyped-decorators `
686+ mypy generates an error if a typed function is wrapped by an untyped decorator
687+ (as this would effectively remove the benefits of typing the function).
688+
689+ Example:
690+
691+ .. code-block :: python
692+
693+ def printing_decorator (func ):
694+ def wrapper (* args , ** kwds ):
695+ print (" Calling" , func)
696+ return func(* args, ** kwds)
697+ return wrapper
698+ # A decorated function.
699+ @printing_decorator # E: Untyped decorator makes function "add_forty_two" untyped [misc]
700+ def add_forty_two (value : int ) -> int :
701+ return value + 42
You can’t perform that action at this time.
0 commit comments