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

Fix crash inferring on NewType named with f-string #1400

Merged
merged 1 commit into from
Feb 19, 2022

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Feb 19, 2022

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

The f-string here:

new_type = NewType(f'IntRange_{t}', t)

was altered by astroid here to remove its final ':

typename = node.args[0].as_string().strip("'")

That caused a string parsing error, since there was an unterminated f-string.
Solution in this PR is to short circuit, rather than cope with a string formatted at runtime.

Type of Changes

Type
🐛 Bug fix

Related Issue

Refs PyCQA/pylint/#5770

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.10.0 milestone Feb 19, 2022
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.

Thank you for finding this crash and fixing it !

Did you check that pylint's tests are still passing with this change ?

@jacobtylerwalls
Copy link
Member Author

Did you check that pylint's tests are still passing with this change ?

They are!


Will a regression test also be needed in Pylint or is this test sufficient?

@Pierre-Sassoulas Pierre-Sassoulas merged commit b196941 into pylint-dev:main Feb 19, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the pylint-tested PRs that don't cause major regressions with pylint label Feb 19, 2022
@Pierre-Sassoulas
Copy link
Member

Will a regression test also be needed in Pylint or is this test sufficient?

We generally close the pylint issue when the regression test is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pylint-tested PRs that don't cause major regressions with pylint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants