Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Skip checking number of interpolations for string formatting when rhs_type is an Iterable type - #11319

Merged
JukkaL merged 4 commits into
python:masterfrom
97littleleaf11:fix-7764
Oct 14, 2021
Merged

Skip checking number of interpolations for string formatting when rhs_type is an Iterable type#11319
JukkaL merged 4 commits into
python:masterfrom
97littleleaf11:fix-7764

Conversation

@97littleleaf11

Copy link
Copy Markdown
Collaborator

Description

Closes #7764

Test Plan

  • Move string formatting test cases into a new file.
  • Add a new test [testStringInterpolationIterableType]

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm it would be more consistent to not complain about iterable types as the RHS, since the number of items could be correct. For example, mypy doesn't complain about this code, which feels quite similar:

a = [1]
x, y = a  # No error, since the number of items could be 2 (mypy doesn't know)

@JukkaL

JukkaL commented Oct 13, 2021

Copy link
Copy Markdown
Collaborator

For a cleaner commit history, it would be nice to have a separate PR that moves the test cases to a new file. If the refactoring is included with the functionality change and somebody would look at the commit history, it could be a little difficult to find the new test case. This is one reason why I usually prefer refactorings in separate PRs.

@97littleleaf11 97littleleaf11 changed the title Change error message for string formatting when rhs_type is an Iterable type Skip checking number of interpolations for string formatting when rhs_type is an Iterable type Oct 14, 2021
@97littleleaf11
97littleleaf11 requested a review from JukkaL October 14, 2021 10:24

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the updates! Looks good.

@JukkaL
JukkaL merged commit a114826 into python:master Oct 14, 2021
@97littleleaf11
97littleleaf11 deleted the fix-7764 branch October 14, 2021 13:43
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
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.

False positive [str-format] for Sequence[]

2 participants