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

Skip to content

Use customized error message for %c interpolation - #10875

Merged
JukkaL merged 7 commits into
python:masterfrom
97littleleaf11:mypy-bytes-c
Jul 26, 2021
Merged

Use customized error message for %c interpolation#10875
JukkaL merged 7 commits into
python:masterfrom
97littleleaf11:mypy-bytes-c

Conversation

@97littleleaf11

@97littleleaf11 97littleleaf11 commented Jul 26, 2021

Copy link
Copy Markdown
Collaborator

Description

This PR is a follow-up to #10869.

  • Add more tests for %c interpolation
  • The error msg of mypy now is bassically the same as CPython. We offer hints for incompatible types.
  • Change type of Checkers from Tuple[Callable[[Expression], None], Callable[[Type], None]] to Tuple[Callable[[Expression], None], Callable[[Type], bool]]. check_expr can get a False from check_type and stop generating same error message.

Test Plan

Adds several new test cases.

CPython behaviors:

'%c' % b''   # E: "%c" requires int or char
'%c' % b'ab' # E: "%c" requires int or char
b'%c' % b''   # E: "%c" requires int or char
b'%c' % b'aa' # E: "%c" requires int or char

@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.

Looks reasonable. Since %c seems to be used extremely rarely, I don't recommend putting more effort into improving it.

@JukkaL
JukkaL merged commit bc1dc95 into python:master Jul 26, 2021
@97littleleaf11
97littleleaf11 deleted the mypy-bytes-c branch July 26, 2021 18:45
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.

2 participants