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

Add documentation for messages with assert in their name #5960

Merged
merged 3 commits into from
Mar 24, 2022

Conversation

DanielNoord
Copy link
Collaborator

  • Add yourself to CONTRIBUTORS.txt if you are a new contributor.
  • Write a good description on what the PR does.

Type of Changes

Type
📜 Docs

Description

Code examples based on pylint-errors and my own work.

Ref. #5953.

These are a bit silly, but oh well... At least it shows how to avoid them.

Co-authored-by: Vladyslav Krylasov <vladyslav.krylasov@gmail.com>
Copy link
Member

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

The example are a bit silly here as it's hard to tell what te code should be. It should probably be "nothing" because the assert is useless ? What about # nothing, the assert was always true

Comment on lines 1 to 7
def test(param):
if param:
assertion_string = "There is an AssertionError"
else:
assertion_string = ""

assert assertion_string
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas Mar 24, 2022

Choose a reason for hiding this comment

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

Suggested change
def test(param):
if param:
assertion_string = "There is an AssertionError"
else:
assertion_string = ""
assert assertion_string
from random import random
def a_function_that_could_fail_the_assert():
if random() > 0.5:
return "something"
return ""
assert a_function_that_could_fail_the_assert()

I think the point is that asserting on a string litteral never fail.

@DanielNoord
Copy link
Collaborator Author

The example are a bit silly here as it's hard to tell what te code should be. It should probably be "nothing" because the assert is useless ? What about # nothing, the assert was always true

Yeah I'm going to change it to say something like that.

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.13.0 milestone Mar 24, 2022
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
@Pierre-Sassoulas Pierre-Sassoulas merged commit e82b43e into pylint-dev:main Mar 24, 2022
@DanielNoord DanielNoord deleted the pylint-errors-1 branch March 24, 2022 20:39
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