Skip to content

Conversation

@Pierre-Sassoulas
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas commented May 1, 2022

Type of Changes

Type
📜 Docs

Description

Follow up to a late review in #6475. I realized that two very close messages where on two different checkers it's minor and hard to fix (it could be just an old name for 'redundant-unittest-assert' to add to ' assert-on-string-literal' otherwise ).

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

I don't really understand the intention of this PR I think. If we want people to know about a similar but different message we could probably add a link in the details.rst of both of these messages.


def test_division():
a = 9 / 3
assert "No ZeroDivisionError were raised" # assert-on-string-literal
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we adding an example for another message here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added an example expecting this code to raise a [redundant-unittest-assert], but I think those two messages should be the same one. I think it can illustrate the two ways to fix the issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But this example is about unittest assertions, not normal assert. I don't think we should merge those.

def test_dummy(self):
actual = "test_result"
self.assertEqual(actual, "expected")
# Nothing, as an assert of a string literal will always pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually kind of like the current example. I think the comment works nicely in details.rst.


def test_division():
a = 9 / 3
assert a == 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we do # nothing above we should also do so here? Note, I actually think we should keep the code instead of the comment.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

details of assert-on-tuple should probably also be updated.

Copy link
Member Author

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Thank you for the review @DanielNoord this looks better indeed.

@Pierre-Sassoulas Pierre-Sassoulas merged commit 1dcb90a into pylint-dev:main May 1, 2022
@Pierre-Sassoulas Pierre-Sassoulas changed the title Add related and details.rst to 'redundant-unittest-assert' doc Add related and details.rst to 'redundant-unittest-assert' style message's doc May 1, 2022
@Pierre-Sassoulas Pierre-Sassoulas deleted the follow-up-to-6475 branch May 1, 2022 21:06
@Pierre-Sassoulas Pierre-Sassoulas removed this from the 2.14.0 milestone May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants