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

Pylint: enable unused-variable check #121

Closed
wants to merge 3 commits into from
Closed

Pylint: enable unused-variable check #121

wants to merge 3 commits into from

Conversation

MartinBasti
Copy link
Contributor

@MartinBasti MartinBasti commented Sep 26, 2016

Modules with too many unused variables have check locally disabled

@stlaz stlaz self-assigned this Sep 27, 2016
Copy link
Contributor

@flo-renaud flo-renaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find one minor comment inline.

@@ -368,7 +369,8 @@ def test_2_automountmap_add_duplicate(self):
"""
Test adding a duplicate direct map.
"""
res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.direct_kw)['result']
api.Command['automountmap_add_indirect'](
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to keep the test for 'result' in the output with:
assert 'result' in api.Command...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case assert is not needed because test is expecting DuplicateError to be raised. So assert is useless there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with your comment.

@MartinBasti
Copy link
Contributor Author

I disagree, I really think that there should not be assert

@flo-renaud
Copy link
Contributor

Agree with you, ACK.

@@ -1225,7 +1226,6 @@ def __lt__(self, other):

def _cmp_sequence(self, pattern, self_start, pat_len):
self_idx = self_start
self_len = len(self)
pat_idx = 0
# and self_idx < self_len
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment as it would be even more confusing then than it is now.

@@ -188,7 +188,7 @@ def test_remove_the_only_connection(self):
returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas)
assert returncode != 0, error1
assert error.count(text) == 1, error2 % error
newseg, err = tasks.create_segment(self.master,
_newseg, err = tasks.create_segment(self.master,
self.master,
self.replicas[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to add indentation here.

@stlaz
Copy link
Contributor

stlaz commented Sep 27, 2016

The changes seem fine except for the two small nitpicks.

This commit removes unused variables or rename variables as "expected to
be unused" by using "_" prefix.

This covers only cases where fix was easy or only one unused variable
was in a module
This commit removes or marks unused variables as "expected to be unused"
by using '_' prefix.
Unused variables may:
* make code less readable
* create dead code
* potentialy hide issues/errors

Enabled check should prevent to leave unused variable in code

Check is locally disabled for modules that fix is not clear or easy or have too many occurences of
unused variables
@stlaz
Copy link
Contributor

stlaz commented Sep 27, 2016

The latest changes fixed the nitpicks mentioned, ACK. Thanks 👍

@stlaz stlaz added the ack Pull Request approved, can be merged label Sep 27, 2016
@MartinBasti MartinBasti added the pushed Pull Request has already been pushed label Sep 27, 2016
@MartinBasti MartinBasti deleted the pylint-unused-var branch October 4, 2016 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
3 participants