The few times I've written decorators, I've always written the arguments as 
*args.  That way avoids problems where inner methods/functions are called 
with/without self or default args. E.g.:

# decorator REQUIRE_MAIN
def REQUIRE_MAIN(procedure):
   def new_proc(*args):
      # args[0] would be the calling instance (i.e., self)
      self = args[0]
      ... # guts of the decorator here
      procedure(*args)
   return new_proc

I don't know if this will help here, but it seems a prudent thing to do, 
since it finesses issues about what gets passed in.

On Monday, May 4, 2020 at 9:21:31 AM UTC-4, Edward K. Ream wrote:
>
> On Mon, May 4, 2020 at 7:44 AM vitalije <[email protected] <javascript:>> 
> wrote:
>
> > I have changed your first test script to work. I am not sure if that is 
> all you wanted.
>
> It fails as in my previous tests.  In leoUndo.py I used your version of 
> g.command_method:
>
> @g.command_method('undo')
> def undo(self, event=None):
>     ... rest of code unchanged
>
> And similarly for the redo method.
>
> The unit test @test clone-marked-nodes then failed:
>
> TypeError: inner_wrapper() missing 1 required positional argument: 'event'
>
> So I changed:
>
> def inner_wrapper(self, event):
>
> to
>
> def inner_wrapper(self, event=None):
>
> I've always had a bad feeling this kind of binding hack.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/39fae45d-60c5-4536-afb4-6e2c2865b477%40googlegroups.com.

Reply via email to