django-tables2 icon indicating copy to clipboard operation
django-tables2 copied to clipboard

render() should have *args, **kwargs as param

Open nerdoc opened this issue 2 years ago • 2 comments

https://github.com/jieter/django-tables2/blob/7a5a1fbf2bb5ce2ebe48e962b00c8ff327fea644/django_tables2/columns/base.py#L356

This method is called and can be declared with various parameters (dynamically determined by introspection) in subclasses.

IDEs like PyCharm help by finding out which params the inherited method has, to show you an error if the signature doesn't match.

So if you e.g. declare a Column like this:

class ActionButtonsColumn(tables.Column):
    def render(self, record: HolidayPolicy, value):
        ...

the IDE places a warning: grafik

By adding *args, **kwargs after value this problem can be solved, and does not impact other things IMHO.

However, I don't know much of the internals of django_tables2, so please feel free to close this issue if you think this is not helpful or affects other subsystems...

nerdoc avatar Apr 30 '23 11:04 nerdoc

You wouldn't replace value with **kwargs, but you could add *args, **kwargs to the signature.

The base render() needs to return value, so you need to make sure it gets an arg for value.

There's a good explanation of this here.

marksweb avatar Jul 13 '23 21:07 marksweb

definitely, I'll change this above. Thanks for the hint.

nerdoc avatar Jul 14 '23 12:07 nerdoc