pylint W0621 unused variable warning due to use of locals()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack DBaaS (Trove) |
New
|
Wishlist
|
Unassigned |
Bug Description
Would the team be open to a patch to remove the use of locals(), which causes a pylint W0621 warning, as an example, this:
def list_access(self, instance, username, hostname=None):
"""Show all databases the given user has access to."""
instance_id = base.getid(
user = common.
url = "/instances/
local_vars = locals()
resp, body = self.api.
if not body:
raise Exception("Call to %s did not return to a body" % url)
return [databases.
...could become:
def list_access(self, instance, username, hostname=None):
"""Show all databases the given user has access to."""
instance_id = base.getid(
user = common.
url = "/instances/
resp, body = self.api.
if not body:
raise Exception("Call to {u} did not return to a body".format(
return [databases.
Perhaps there is some good reason for the current approach, which I've been unable to grasp.
I'd be grateful for feedback, happy to work on a patch if it is thought useful.
Changed in trove: | |
importance: | Undecided → Wishlist |
Sure, please submit a patch. But please also consider the following before you do.
trove runs pylint on the code base as part of every commit; see tools/trove-pylint. But, we currently do not look for warnings; pylint is run with -E.
If you'd like to fix this bug, then you will notice that there are 5081 warnings which we currently ignore (because of -E) and the warning W0621 occurs 19 times.
Speaking only for myself, the patch you submit is most welcome if it includes some tooling (such as a change to the pylint tool that we do run) to prevent the same error from creeping back into the code base, and a good reason why this particular warning (which occurs 19 times) is worthy of special treatment over the 5081 warnings that we ignore along with the many errors which we also ignore.
As to why the code is this way, I didn't look.