Skip to content

Commit a586b8e

Browse files
docu
1 parent 6b0f0d8 commit a586b8e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/source/error_code_list2.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)