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 a check for asserts on string literals #3346

Merged

Conversation

anubh-v
Copy link
Contributor

@anubh-v anubh-v commented Jan 14, 2020

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

This PR adds a warning for assert statements that have string literals as their first argument.
Such assert statements will never fail.

Type of Changes

Type
✨ New feature

Related Issue

Fixes #3284

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

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

Great stuff! Can you add a Changelog entry for this and some tests?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.006%) to 89.877% when pulling 1fc127a on anubh-v:warn-assert-first-arg-is-string-literal into be87624 on PyCQA:master.

@coveralls
Copy link

coveralls commented Jan 14, 2020

Coverage Status

Coverage increased (+0.002%) to 89.885% when pulling 8f91c81 on anubh-v:warn-assert-first-arg-is-string-literal into be87624 on PyCQA:master.

@anubh-v anubh-v marked this pull request as ready for review January 14, 2020 12:25
@anubh-v
Copy link
Contributor Author

anubh-v commented Jan 14, 2020

@PCManticore, is there any specific numbering to follow for the warning code? I have used W0129 for this new check, but it seems codes in the range W0110 - W0121 are also available.

@anubh-v anubh-v changed the title Warn about asserts on string literals Add a check for asserts on string literals Jan 14, 2020
@PCManticore
Copy link
Contributor

@anubh-v To answer your question, the codes are usually tied to the checker, you cannot mix and match codes from one checker to another. Other than that, they should be unique so any code that's not taken should be good to go. And if your code was not unique, tests would have failed any way.

@PCManticore PCManticore merged commit f2f4e6f into pylint-dev:master Jan 14, 2020
@PCManticore
Copy link
Contributor

Thank you for the PR! 🎉

@anubh-v anubh-v deleted the warn-assert-first-arg-is-string-literal branch February 12, 2020 07:07
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

Successfully merging this pull request may close these issues.

warning when asserts have a string literal as condition
3 participants