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

Bugfix/enum crash/pylint-3365 #747

Closed
wants to merge 2 commits into from
Closed

Bugfix/enum crash/pylint-3365 #747

wants to merge 2 commits into from

Conversation

martimlobao
Copy link

Steps

  • For new features or bug fixes, add a ChangeLog entry describing what your PR does.
  • Write a good description on what the PR does.

Description

Fixes a pylint crash caused by an IndexError exception when running pylint on any file that has a with ... as in an enum class.

Example:

import enum

class Error(enum.Enum):
    Foo = "foo"
    Bar = "bar"
    with "error" as err:
        pass

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Related Issue

Closes pylint-dev/pylint#3365

@martimlobao martimlobao changed the title Bugfix/enum crash/pylint 3365 Bugfix/enum crash/pylint-3365 Jan 24, 2020
@martimlobao martimlobao requested a review from hippo91 January 24, 2020 20:54
Copy link
Contributor

@hippo91 hippo91 left a comment

Choose a reason for hiding this comment

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

@martimlobao thanks a lot for this contribution.
The modification looks good to me however it would be quite interesting to have unit tests that show the current behaviour of pylint when enum class have with ... as structure.

@PCManticore
Copy link
Contributor

@martimlobao Thanks for the PR! Unfortunately the root cause of the issue was our Enum transform, which was dropping the attributes that it could not understand from the class's locals., such as those for With nodes.

78e56c6 should fix this properly.

@martimlobao
Copy link
Author

@PCManticore Awesome, thanks for fixing the real underlying issue then!

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.

pylint crashes when "with ... as" is used in an enum
3 participants