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

Report precise location for invalid conversion flag #7809

Merged
merged 1 commit into from
Oct 5, 2023

Conversation

dhruvmanila
Copy link
Member

Summary

This PR updates the parser definition to use the precise location when reporting
an invalid f-string conversion flag error.

Taking the following example code:

f"{foo!x}"

On earlier version,

Error: f-string: invalid conversion character at byte offset 6

Now,

Error: f-string: invalid conversion character at byte offset 7

This becomes more useful when there's whitespace between ! and the flag value
although that is not valid but we can't detect that now.

Test Plan

As mentioned above.

@dhruvmanila
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@dhruvmanila dhruvmanila added the bug Something isn't working label Oct 4, 2023
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 4, 2023

CodSpeed Performance Report

Merging #7809 will degrade performances by 2.5%

Comparing dhruv/conversion-flag-loc (dc9270b) with main (a1509df)

Summary

❌ 1 regressions
✅ 24 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main dhruv/conversion-flag-loc Change
linter/default-rules[pydantic/types.py] 38 ms 39 ms -2.5%

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@dhruvmanila dhruvmanila changed the title Precise location for reporting invalid conversion flag Report precise location for invalid conversion flag Oct 5, 2023
@dhruvmanila dhruvmanila merged commit 17fba99 into main Oct 5, 2023
15 of 16 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/conversion-flag-loc branch October 5, 2023 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant