Skip to content

Commit c716b57

Browse files
committed
Rename __role__ to _role and make it kw-only
1 parent 2d70e22 commit c716b57

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/functools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ def _is_valid_dispatch_type(cls):
981981
return (isinstance(cls, UnionType) and
982982
all(isinstance(arg, type) for arg in cls.__args__))
983983

984-
def register(cls, func=None, __role__="function"):
984+
def register(cls, func=None, *, _role="function"):
985985
"""generic_func.register(cls, func) -> func
986986
987987
Registers a new implementation for the given *cls* on a *generic_func*.
@@ -1006,7 +1006,7 @@ def register(cls, func=None, __role__="function"):
10061006
)
10071007
func = cls
10081008

1009-
argname = _get_singledispatch_annotated_param(func, role=__role__)
1009+
argname = _get_singledispatch_annotated_param(func, role=_role)
10101010

10111011
# only import typing if annotation parsing is necessary
10121012
from typing import get_type_hints
@@ -1058,7 +1058,7 @@ def wrapper(*args, **kw):
10581058
funcname = getattr(func, '__name__', 'singledispatch function')
10591059
registry[object] = func
10601060
wrapper.register = register
1061-
wrapper.register.__text_signature__ = "(cls, func)" # Hide __role__ from help().
1061+
wrapper.register.__text_signature__ = "(cls, func)" # Hide _role from help().
10621062
wrapper.dispatch = dispatch
10631063
wrapper.registry = MappingProxyType(registry)
10641064
wrapper._clear_cache = dispatch_cache.clear
@@ -1086,7 +1086,7 @@ def register(self, cls, method=None):
10861086
10871087
Registers a new implementation for the given *cls* on a *generic_method*.
10881088
"""
1089-
return self.dispatcher.register(cls, func=method, __role__="method")
1089+
return self.dispatcher.register(cls, func=method, _role="method")
10901090

10911091
def __get__(self, obj, cls=None):
10921092
return _singledispatchmethod_get(self, obj, cls)

0 commit comments

Comments
 (0)