| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1140,7 +1140,7 @@ variants of :func:`functools.lru_cache`:: | |||
| 1140 | 1140 | class LRU(OrderedDict): | |
| 1141 | 1141 | 'Limit size, evicting the least recently looked-up key when full' | |
| 1142 | 1142 | ||
| 1143 | - def __init__(self, maxsize=128, *args, **kwds): | ||
| 1143 | + def __init__(self, maxsize=128, /, *args, **kwds): | ||
| 1144 | 1144 | self.maxsize = maxsize | |
| 1145 | 1145 | super().__init__(*args, **kwds) | |
| 1146 | 1146 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -637,7 +637,7 @@ even further by means of a small helper class:: | |||
| 637 | 637 | from contextlib import ExitStack | |
| 638 | 638 | ||
| 639 | 639 | class Callback(ExitStack): | |
| 640 | - def __init__(self, callback, *args, **kwds): | ||
| 640 | + def __init__(self, callback, /, *args, **kwds): | ||
| 641 | 641 | super(Callback, self).__init__() | |
| 642 | 642 | self.callback(callback, *args, **kwds) | |
| 643 | 643 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,7 +107,7 @@ headers. | |||
| 107 | 107 | method if it wishes to set additional attributes beyond those provided by | |
| 108 | 108 | ``BaseHeader`` itself. Such an ``init`` method should look like this:: | |
| 109 | 109 | ||
| 110 | - def init(self, *args, **kw): | ||
| 110 | + def init(self, /, *args, **kw): | ||
| 111 | 111 | self._myattr = kw.pop('myattr') | |
| 112 | 112 | super().init(*args, **kw) | |
| 113 | 113 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -221,7 +221,7 @@ The :mod:`functools` module defines the following functions: | |||
| 221 | 221 | Returning NotImplemented from the underlying comparison function for | |
| 222 | 222 | unrecognised types is now supported. | |
| 223 | 223 | ||
| 224 | - .. function:: partial(func, *args, **keywords) | ||
| 224 | + .. function:: partial(func, /, *args, **keywords) | ||
| 225 | 225 | ||
| 226 | 226 | Return a new :ref:`partial object<partial-objects>` which when called | |
| 227 | 227 | will behave like *func* called with the positional arguments *args* | |
@@ -230,7 +230,7 @@ The :mod:`functools` module defines the following functions: | |||
| 230 | 230 | supplied, they extend and override *keywords*. | |
| 231 | 231 | Roughly equivalent to:: | |
| 232 | 232 | ||
| 233 | - def partial(func, *args, **keywords): | ||
| 233 | + def partial(func, /, *args, **keywords): | ||
| 234 | 234 | def newfunc(*fargs, **fkeywords): | |
| 235 | 235 | newkeywords = {**keywords, **fkeywords} | |
| 236 | 236 | return func(*args, *fargs, **newkeywords) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1022,7 +1022,7 @@ Classes and functions | |||
| 1022 | 1022 | metatype is in use, cls will be the first element of the tuple. | |
| 1023 | 1023 | ||
| 1024 | 1024 | ||
| 1025 | - .. function:: getcallargs(func, *args, **kwds) | ||
| 1025 | + .. function:: getcallargs(func, /, *args, **kwds) | ||
| 1026 | 1026 | ||
| 1027 | 1027 | Bind the *args* and *kwds* to the argument names of the Python function or | |
| 1028 | 1028 | method *func*, as if it was called with them. For bound methods, bind also the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -339,7 +339,7 @@ expect a function argument. | |||
| 339 | 339 | [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)] | |
| 340 | 340 | ||
| 341 | 341 | ||
| 342 | - .. function:: methodcaller(name[, args...]) | ||
| 342 | + .. function:: methodcaller(name, /, *args, **kwargs) | ||
| 343 | 343 | ||
| 344 | 344 | Return a callable object that calls the method *name* on its operand. If | |
| 345 | 345 | additional arguments and/or keyword arguments are given, they will be given | |
@@ -352,7 +352,7 @@ expect a function argument. | |||
| 352 | 352 | ||
| 353 | 353 | Equivalent to:: | |
| 354 | 354 | ||
| 355 | - def methodcaller(name, *args, **kwargs): | ||
| 355 | + def methodcaller(name, /, *args, **kwargs): | ||
| 356 | 356 | def caller(obj): | |
| 357 | 357 | return getattr(obj, name)(*args, **kwargs) | |
| 358 | 358 | return caller | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,7 +88,7 @@ implementation as the built-in :meth:`~str.format` method. | |||
| 88 | 88 | ||
| 89 | 89 | The :class:`Formatter` class has the following public methods: | |
| 90 | 90 | ||
| 91 | - .. method:: format(format_string, *args, **kwargs) | ||
| 91 | + .. method:: format(format_string, /, *args, **kwargs) | ||
| 92 | 92 | ||
| 93 | 93 | The primary API method. It takes a format string and | |
| 94 | 94 | an arbitrary set of positional and keyword arguments. | |
@@ -720,7 +720,7 @@ these rules. The methods of :class:`Template` are: | |||
| 720 | 720 | The constructor takes a single argument which is the template string. | |
| 721 | 721 | ||
| 722 | 722 | ||
| 723 | - .. method:: substitute(mapping, **kwds) | ||
| 723 | + .. method:: substitute(mapping={}, /, **kwds) | ||
| 724 | 724 | ||
| 725 | 725 | Performs the template substitution, returning a new string. *mapping* is | |
| 726 | 726 | any dictionary-like object with keys that match the placeholders in the | |
@@ -729,7 +729,7 @@ these rules. The methods of :class:`Template` are: | |||
| 729 | 729 | and there are duplicates, the placeholders from *kwds* take precedence. | |
| 730 | 730 | ||
| 731 | 731 | ||
| 732 | - .. method:: safe_substitute(mapping, **kwds) | ||
| 732 | + .. method:: safe_substitute(mapping={}, /, **kwds) | ||
| 733 | 733 | ||
| 734 | 734 | Like :meth:`substitute`, except that if placeholders are missing from | |
| 735 | 735 | *mapping* and *kwds*, instead of raising a :exc:`KeyError` exception, the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -327,7 +327,7 @@ Additional Utility Classes and Functions | |||
| 327 | 327 | The type is roughly equivalent to the following code:: | |
| 328 | 328 | ||
| 329 | 329 | class SimpleNamespace: | |
| 330 | - def __init__(self, **kwargs): | ||
| 330 | + def __init__(self, /, **kwargs): | ||
| 331 | 331 | self.__dict__.update(kwargs) | |
| 332 | 332 | ||
| 333 | 333 | def __repr__(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -848,7 +848,7 @@ Here's an example implementation: | |||
| 848 | 848 | ||
| 849 | 849 | >>> from copy import deepcopy | |
| 850 | 850 | >>> class CopyingMock(MagicMock): | |
| 851 | - ... def __call__(self, *args, **kwargs): | ||
| 851 | + ... def __call__(self, /, *args, **kwargs): | ||
| 852 | 852 | ... args = deepcopy(args) | |
| 853 | 853 | ... kwargs = deepcopy(kwargs) | |
| 854 | 854 | ... return super(CopyingMock, self).__call__(*args, **kwargs) | |
@@ -1042,7 +1042,7 @@ that it takes arbitrary keyword arguments (``**kwargs``) which are then passed | |||
| 1042 | 1042 | onto the mock constructor: | |
| 1043 | 1043 | ||
| 1044 | 1044 | >>> class Subclass(MagicMock): | |
| 1045 | - ... def _get_child_mock(self, **kwargs): | ||
| 1045 | + ... def _get_child_mock(self, /, **kwargs): | ||
| 1046 | 1046 | ... return MagicMock(**kwargs) | |
| 1047 | 1047 | ... | |
| 1048 | 1048 | >>> mymock = Subclass() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1456,7 +1456,7 @@ Test cases | |||
| 1456 | 1456 | ||
| 1457 | 1457 | .. versionadded:: 3.1 | |
| 1458 | 1458 | ||
| 1459 | - .. classmethod:: addClassCleanup(function, *args, **kwargs) | ||
| 1459 | + .. classmethod:: addClassCleanup(function, /, *args, **kwargs) | ||
| 1460 | 1460 | ||
| 1461 | 1461 | Add a function to be called after :meth:`tearDownClass` to cleanup | |
| 1462 | 1462 | resources used during the test class. Functions will be called in reverse | |
@@ -2313,7 +2313,7 @@ To add cleanup code that must be run even in the case of an exception, use | |||
| 2313 | 2313 | ``addModuleCleanup``: | |
| 2314 | 2314 | ||
| 2315 | 2315 | ||
| 2316 | - .. function:: addModuleCleanup(function, *args, **kwargs) | ||
| 2316 | + .. function:: addModuleCleanup(function, /, *args, **kwargs) | ||
| 2317 | 2317 | ||
| 2318 | 2318 | Add a function to be called after :func:`tearDownModule` to cleanup | |
| 2319 | 2319 | resources used during the test class. Functions will be called in reverse | |
| Back | FazBrowse Home | New Git URL |
0 commit comments