Skip to content

Commit 03b9537

Browse files
authored
bpo-31567: more decorator markup fixes in docs (GH-3959) (#3966)
1 parent cba9a0c commit 03b9537

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Doc/library/functions.rst

+11-2
Original file line numberDiff line numberDiff line change
@@ -1419,12 +1419,21 @@ are always available. They are listed here in alphabetical order.
14191419
:func:`classmethod` for a variant that is useful for creating alternate class
14201420
constructors.
14211421

1422+
Like all decorators, it is also possible to call ``staticmethod`` as
1423+
a regular function and do something with its result. This is needed
1424+
in some cases where you need a reference to a function from a class
1425+
body and you want to avoid the automatic transformation to instance
1426+
method. For these cases, use this idiom:
1427+
1428+
class C:
1429+
builtin_open = staticmethod(open)
1430+
14221431
For more information on static methods, consult the documentation on the
14231432
standard type hierarchy in :ref:`types`.
14241433

1425-
.. index::
1426-
single: string; str() (built-in function)
14271434

1435+
.. index::
1436+
single: string; str() (built-in function)
14281437

14291438
.. _func-str:
14301439
.. class:: str(object='')

Doc/library/typing.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -897,17 +897,17 @@ The module defines the following classes, functions and decorators:
897897

898898
See :pep:`484` for details and comparison with other typing semantics.
899899

900-
.. decorator:: no_type_check(arg)
900+
.. decorator:: no_type_check
901901

902902
Decorator to indicate that annotations are not type hints.
903903

904-
The argument must be a class or function; if it is a class, it
904+
This works as class or function :term:`decorator`. With a class, it
905905
applies recursively to all methods defined in that class (but not
906906
to methods defined in its superclasses or subclasses).
907907

908908
This mutates the function(s) in place.
909909

910-
.. decorator:: no_type_check_decorator(decorator)
910+
.. decorator:: no_type_check_decorator
911911

912912
Decorator to give another decorator the :func:`no_type_check` effect.
913913

Lib/test/test_typing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1471,8 +1471,8 @@ class D(C):
14711471
def test_meta_no_type_check(self):
14721472

14731473
@no_type_check_decorator
1474-
def magic_decorator(deco):
1475-
return deco
1474+
def magic_decorator(func):
1475+
return func
14761476

14771477
self.assertEqual(magic_decorator.__name__, 'magic_decorator')
14781478

0 commit comments

Comments
 (0)