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

Update Q000, Q001 with the new f-string tokens #7589

Merged
merged 4 commits into from
Sep 27, 2023

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Sep 22, 2023

Summary

This PR updates the Q000, and Q001 rules to consider the new f-string tokens. The docstring rule (Q002) doesn't need to be updated because f-strings cannot be used as docstrings.

I tried implementing the nested f-string support but there are still some edge cases in my current implementation so I've decided to pause it for now and I'll pick it up sometime soon. So, for now this doesn't support nested f-strings.

Implementation

The implementation uses the same FStringRangeBuilder introduced in #7586 to build up the outermost f-string range. The reason to use the same implementation is because this is a temporary solution until we add support for nested f-strings.

Test Plan

cargo test

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 22, 2023

CodSpeed Performance Report

Merging #7589 will not alter performance

Comparing dhruv/issue-7297-2 (715b5df) with dhruv/issue-7297 (7753ce8)

Summary

✅ 25 untouched benchmarks

@dhruvmanila dhruvmanila changed the title Update Q000-002 with the new f-string tokens Update Q000, Q001 with the new f-string tokens Sep 22, 2023
@dhruvmanila dhruvmanila added rule Implementing or modifying a lint rule python312 Related to Python 3.12 labels Sep 22, 2023
@dhruvmanila dhruvmanila linked an issue Sep 22, 2023 that may be closed by this pull request
@dhruvmanila dhruvmanila marked this pull request as ready for review September 22, 2023 06:02
Base automatically changed from dhruv/issue-7297 to dhruv/pep-701 September 27, 2023 07:57
@dhruvmanila dhruvmanila merged commit f836820 into dhruv/pep-701 Sep 27, 2023
1 of 13 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/issue-7297-2 branch September 27, 2023 08:04
dhruvmanila added a commit that referenced this pull request Sep 28, 2023
## Summary

This PR updates the `Q000`, and `Q001` rules to consider the new
f-string tokens. The docstring rule (`Q002`) doesn't need to be updated
because f-strings cannot be used as docstrings.

I tried implementing the nested f-string support but there are still
some edge cases in my current implementation so I've decided to pause it
for now and I'll pick it up sometime soon. So, for now this doesn't
support nested f-strings.

### Implementation

The implementation uses the same `FStringRangeBuilder` introduced in
#7586 to build up the outermost f-string range. The reason to use the
same implementation is because this is a temporary solution until we add
support for nested f-strings.

## Test Plan

`cargo test`
dhruvmanila added a commit that referenced this pull request Sep 29, 2023