@@ -724,16 +724,16 @@ def _make_sub_context(self, command: Command) -> Context:
724
724
725
725
@t .overload
726
726
def invoke (
727
- __self , __callback : t .Callable [..., V ], * args : t .Any , ** kwargs : t .Any
727
+ self , callback : t .Callable [..., V ], / , * args : t .Any , ** kwargs : t .Any
728
728
) -> V :
729
729
...
730
730
731
731
@t .overload
732
- def invoke (__self , __callback : Command , * args : t .Any , ** kwargs : t .Any ) -> t .Any :
732
+ def invoke (self , callback : Command , / , * args : t .Any , ** kwargs : t .Any ) -> t .Any :
733
733
...
734
734
735
735
def invoke (
736
- __self , __callback : Command | t .Callable [..., V ], * args : t .Any , ** kwargs : t .Any
736
+ self , callback : Command | t .Callable [..., V ], / , * args : t .Any , ** kwargs : t .Any
737
737
) -> t .Any | V :
738
738
"""Invokes a command callback in exactly the way it expects. There
739
739
are two ways to invoke this method:
@@ -752,17 +752,17 @@ def invoke(
752
752
.. versionchanged:: 3.2
753
753
A new context is created, and missing arguments use default values.
754
754
"""
755
- if isinstance (__callback , Command ):
756
- other_cmd = __callback
755
+ if isinstance (callback , Command ):
756
+ other_cmd = callback
757
757
758
758
if other_cmd .callback is None :
759
759
raise TypeError (
760
760
"The given command does not have a callback that can be invoked."
761
761
)
762
762
else :
763
- __callback = t .cast ("t.Callable[..., V]" , other_cmd .callback )
763
+ callback = t .cast ("t.Callable[..., V]" , other_cmd .callback )
764
764
765
- ctx = __self ._make_sub_context (other_cmd )
765
+ ctx = self ._make_sub_context (other_cmd )
766
766
767
767
for param in other_cmd .params :
768
768
if param .name not in kwargs and param .expose_value :
@@ -774,13 +774,13 @@ def invoke(
774
774
# them on in subsequent calls.
775
775
ctx .params .update (kwargs )
776
776
else :
777
- ctx = __self
777
+ ctx = self
778
778
779
- with augment_usage_errors (__self ):
779
+ with augment_usage_errors (self ):
780
780
with ctx :
781
- return __callback (* args , ** kwargs )
781
+ return callback (* args , ** kwargs )
782
782
783
- def forward (__self , __cmd : Command , * args : t .Any , ** kwargs : t .Any ) -> t .Any :
783
+ def forward (self , cmd : Command , / , * args : t .Any , ** kwargs : t .Any ) -> t .Any :
784
784
"""Similar to :meth:`invoke` but fills in default keyword
785
785
arguments from the current context if the other command expects
786
786
it. This cannot invoke callbacks directly, only other commands.
@@ -790,14 +790,14 @@ def forward(__self, __cmd: Command, *args: t.Any, **kwargs: t.Any) -> t.Any:
790
790
passed if ``forward`` is called at multiple levels.
791
791
"""
792
792
# Can only forward to other commands, not direct callbacks.
793
- if not isinstance (__cmd , Command ):
793
+ if not isinstance (cmd , Command ):
794
794
raise TypeError ("Callback is not a command." )
795
795
796
- for param in __self .params :
796
+ for param in self .params :
797
797
if param not in kwargs :
798
- kwargs [param ] = __self .params [param ]
798
+ kwargs [param ] = self .params [param ]
799
799
800
- return __self .invoke (__cmd , * args , ** kwargs )
800
+ return self .invoke (cmd , * args , ** kwargs )
801
801
802
802
def set_parameter_source (self , name : str , source : ParameterSource ) -> None :
803
803
"""Set the source of a parameter. This indicates the location
@@ -1674,8 +1674,8 @@ def decorator(f: F) -> F:
1674
1674
self ._result_callback = f
1675
1675
return f
1676
1676
1677
- def function (__value , * args , ** kwargs ): # type: ignore
1678
- inner = old_callback (__value , * args , ** kwargs )
1677
+ def function (value : t . Any , / , * args : t . Any , ** kwargs : t . Any ) -> t . Any :
1678
+ inner = old_callback (value , * args , ** kwargs )
1679
1679
return f (inner , * args , ** kwargs )
1680
1680
1681
1681
self ._result_callback = rv = update_wrapper (t .cast (F , function ), f )
0 commit comments