First of all, I'm super new to stackoverflow and don't really know a lot about how to ask questions and all, so please excuse any major mistakes I made.
Anyways, I'm currently trying to create a way for functions to reference themselves. For that I have created a wrapper which looks like this:
def custom_self(func):
def wrapped(*args, **kwargs):
return func(func, *args, **kwargs)
return wrapped
Pretty standard stuff, honestly. I can now use this wrapper as a decorator on any new function which is supposed to reference itself. However, I'm using Visual Studio Code as editor and whenever I hover over my new function it shows something like this:
Screenshot (Sorry, apparently I'm not allowed to add pictures yet)
Now, as you can see, the code lens shows all parameters the function requires. However this includes the parameter 'own' which is supposed to be a reference to the function itself. Therefore it isn't a parameter, that you can actually pass to the function, similar to how class methods work. My question now is: How can I make it so that the code lens only shows the parameters 'arg_1' and 'arg_2'?
(This is what is displayed. As you can see the editor thinks I pass the parameter 'own' when actually I'm passing the parameter 'arg_1'. The code works just as I want it to but the displaying kinda fails.)
I already tried using 'typing.overload' as a decorator like so:
@typing.overload
def new_func(arg_1, arg_2): ...
@custom_self
def new_func(own, arg_1, arg_2):
own.arg_1 = arg_1
own.arg_2 = arg_2
...
This works and the code lens now only shows 'arg_1' and 'arg_2' as parameters, but let's just be honest, this is not a very pretty solution, because it means I have to create a dummy for every self-referencing function and I also have to declare every function twice, which makes it less 'pythonic', I guess.
I have also tried to decorate the 'custom_self' function, but this also didn't get me the desired result.
Again, the code works just fine, this is just a display error. But it's a rather annoying one at that.