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 check to make sure only strings are assigned to __name__ #3271

Merged
merged 7 commits into from
Dec 16, 2019
Merged

Add check to make sure only strings are assigned to __name__ #3271

merged 7 commits into from
Dec 16, 2019

Conversation

ninezerozeronine
Copy link
Contributor

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 adds a new check to make sure that only strings are assigned to __name__ attributes.

Type of Changes

Type
✨ New feature

Related Issue

Closes #583

@ninezerozeronine
Copy link
Contributor Author

Putting this in as a draft to check I'm going in the right direction.

I'd like to:

  • Add inference to detect things like:
def return_string():
    return "foo"

def my_func():
    pass

my_func.__name__ = return_string()
  • Investigate how using inference relates to confidence levels and add this to the check output if necessary.
  • Improve check output to include more details of why the check failed.

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.

Hey @ninezerozeronine

Thank you for sending this PR! Overall it's looking great, left a bunch of comments to be addressed before we can pull this in.

pylint/checkers/typecheck.py Outdated Show resolved Hide resolved
pylint/checkers/typecheck.py Outdated Show resolved Hide resolved
pylint/checkers/typecheck.py Outdated Show resolved Hide resolved
@ninezerozeronine
Copy link
Contributor Author

Thank you for the advice and examples Claudiu! I'm hoping to take a stab at this this weekend.

@ninezerozeronine ninezerozeronine marked this pull request as ready for review December 8, 2019 21:54
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 89.864% when pulling d0851ab on ninezerozeronine:feature/check-dundername-is-string into 1e84b02 on PyCQA:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 89.864% when pulling d0851ab on ninezerozeronine:feature/check-dundername-is-string into 1e84b02 on PyCQA:master.

@coveralls
Copy link

coveralls commented Dec 8, 2019

Coverage Status

Coverage increased (+0.02%) to 89.865% when pulling d0851ab on ninezerozeronine:feature/check-dundername-is-string into 1e84b02 on PyCQA:master.

@PCManticore PCManticore merged commit dc83a86 into pylint-dev:master Dec 16, 2019
@PCManticore
Copy link
Contributor

Thanks a lot for the patch @ninezerozeronine !

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.

[easy] can assign only strings to __name__
3 participants