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

Warning for view functions #155

Closed
Li-ReDBox opened this issue Apr 9, 2018 · 2 comments
Closed

Warning for view functions #155

Li-ReDBox opened this issue Apr 9, 2018 · 2 comments

Comments

@Li-ReDBox
Copy link

Django's view functions have signature of request. Even I don't use reqest, I would like to include it as part of signature. But if I run:

pylint --load-plugins pylint_django views.py

W:184,12: Unused argument 'request' (unused-argument)

My question is: is there a way to surpass this warning?

@atodorov
Copy link
Contributor

atodorov commented Apr 9, 2018

Right now you can disable with # pylint: disable=unused-argument or rename to _request.

It should be possible to teach pylint_django to ignore this error but I'll have to see how to do that. May not be very easy though.

@Li-ReDBox
Copy link
Author

Thanks @atodorov for replying. Change the argument to _request does not look like a bad idea. How pylint treats some functions with signature of func(arg1, arg2, *args, **kwargs) which is the common pattern of Django's view class methods?

atodorov added a commit that referenced this issue May 24, 2018
in fact we disable this error just based on the argument name.
For functions it is not really possible to reliably determine if
the function is a real view that serves http requests or a
plain-old-function (maybe a helper) where the argument was named
'request'.
atodorov added a commit that referenced this issue May 24, 2018
in fact we disable this error just based on the argument name.
For functions it is not really possible to reliably determine if
the function is a real view that serves http requests or a
plain-old-function (maybe a helper) where the argument was named
'request'.
psrb added a commit to psrb/pylint-django that referenced this issue Oct 27, 2019
…v#249)

The previous implementation (result of pylint-dev#155) of disabling the
unused-argument warning for functions/methods having an argument named
`request` was to broad. As soon as a function/method contains a
`request` argument no unused-argument warning will be issued for this
function anymore, even though some other arguments are unused!

This commit extends the `ignored-argument-names` regex of Pylint to also
ignore arguments named `request`. This way unused-argument warnings will
still be issued for every other unused argument of the function/method.
psrb added a commit to psrb/pylint-django that referenced this issue Oct 30, 2019
…v#249)

The previous implementation (result of pylint-dev#155) of disabling the
unused-argument warning for functions/methods having an argument named
`request` was to broad. As soon as a function/method contains a
`request` argument no unused-argument warning will be issued for this
function anymore, even though some other arguments are unused!

This commit extends the `ignored-argument-names` regex of Pylint to also
ignore arguments named `request`. This way unused-argument warnings will
still be issued for every other unused argument of the function/method.
psrb added a commit to psrb/pylint-django that referenced this issue Oct 30, 2019
…v#249)

The previous implementation (result of pylint-dev#155) of disabling the
unused-argument warning for functions/methods having an argument named
`request` was to broad. As soon as a function/method contains a
`request` argument no unused-argument warning will be issued for this
function anymore, even though some other arguments are unused!

This commit extends the `ignored-argument-names` regex of Pylint to also
ignore arguments named `request`. This way unused-argument warnings will
still be issued for every other unused argument of the function/method.
atodorov pushed a commit that referenced this issue Oct 31, 2019
The previous implementation (result of #155) of disabling the
unused-argument warning for functions/methods having an argument named
`request` was to broad. As soon as a function/method contains a
`request` argument no unused-argument warning will be issued for this
function anymore, even though some other arguments are unused!

This commit extends the `ignored-argument-names` regex of Pylint to also
ignore arguments named `request`. This way unused-argument warnings will
still be issued for every other unused argument of the function/method.
psrb added a commit to psrb/pylint-django that referenced this issue Nov 3, 2019
…v#249)

The previous implementation (result of pylint-dev#155) of disabling the
unused-argument warning for functions/methods having an argument named
`request` was to broad. As soon as a function/method contains a
`request` argument no unused-argument warning will be issued for this
function anymore, even though some other arguments are unused!

This commit monkey patches `VariablesChecker._is_ignored_named` to
specifically suppress the generation of unused-argument warnings for
arguments named `request`.
This way unused-argument warnings will still be issued for every other
unused argument of the function/method.
atodorov pushed a commit that referenced this issue Nov 4, 2019
The previous implementation (result of #155) of disabling the
unused-argument warning for functions/methods having an argument named
`request` was to broad. As soon as a function/method contains a
`request` argument no unused-argument warning will be issued for this
function anymore, even though some other arguments are unused!

This commit monkey patches `VariablesChecker._is_ignored_named` to
specifically suppress the generation of unused-argument warnings for
arguments named `request`.
This way unused-argument warnings will still be issued for every other
unused argument of the function/method.
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