@@ -19,13 +19,16 @@ file if you are using one).
19
19
20
20
In the extension type (a.k.a. ``cdef class``) for which you want to
21
21
define a metaclass, define a method ``__getmetaclass__`` with a single
22
- unused argument. This method should return a type to be used as
22
+ unused argument, and turn off the Cython directive
23
+ ``always_allow_keywords``. This method should return a type to be used as
23
24
metaclass:
24
25
25
26
.. code-block:: cython
26
27
28
+ cimport cython
27
29
cimport sage.cpython.cython_metaclass
28
30
cdef class MyCustomType():
31
+ @cython.always_allow_keywords(False)
29
32
def __getmetaclass__(_):
30
33
from foo import MyMetaclass
31
34
return MyMetaclass
@@ -63,8 +66,10 @@ EXAMPLES::
63
66
64
67
sage: cython( # needs sage.misc.cython
65
68
....: '''
69
+ ....: cimport cython
66
70
....: cimport sage.cpython.cython_metaclass
67
71
....: cdef class MyCustomType():
72
+ ....: @cython.always_allow_keywords(False)
68
73
....: def __getmetaclass__(_):
69
74
....: class MyMetaclass(type):
70
75
....: def __init__(*args):
@@ -101,8 +106,10 @@ returns a non-type::
101
106
102
107
sage: cython( # needs sage.misc.cython
103
108
....: '''
109
+ ....: cimport cython
104
110
....: cimport sage.cpython.cython_metaclass
105
111
....: cdef class MyCustomType():
112
+ ....: @cython.always_allow_keywords(False)
106
113
....: def __getmetaclass__(_):
107
114
....: return 2
108
115
....: ''')
0 commit comments