Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nerdoc opened this issue Apr 30, 2023 · 2 comments
Open

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

nerdoc opened this issue Apr 30, 2023 · 2 comments

Comments

@nerdoc
Copy link

nerdoc commented Apr 30, 2023

def render(self, value):

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...

@marksweb
Copy link

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.

@nerdoc
Copy link
Author

nerdoc commented Jul 14, 2023

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

@nerdoc nerdoc changed the title render() should have **kwargs as param render() should have *args, **kwargs as param Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants