Skip to content

Conversation

@dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Oct 4, 2023

Summary

This PR fixes the bug where the formatter would panic if a class/function with
decorators had a suppression comment.

The fix is to use to correct start location to find the async/def/class
keyword when decorators are present which is the end of the last decorator.

Test Plan

Add test cases for the fix and update the snapshots.

@dhruvmanila
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@dhruvmanila dhruvmanila added bug Something isn't working formatter Related to the formatter labels Oct 4, 2023
@dhruvmanila dhruvmanila requested a review from konstin October 4, 2023 05:36
@dhruvmanila dhruvmanila force-pushed the dhruv/start-location branch from 26fb68e to 4bed0d5 Compare October 4, 2023 06:43
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 4, 2023

CodSpeed Performance Report

Merging #7802 will degrade performances by 2.37%

Comparing dhruv/start-location (b79b73d) with main (7b4fb4f)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 23 untouched benchmarks

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

Benchmarks breakdown

Benchmark main dhruv/start-location Change
linter/default-rules[pydantic/types.py] 38.9 ms 38 ms +2.48%
linter/all-rules[numpy/ctypeslib.py] 34.6 ms 35.5 ms -2.37%

@konstin
Copy link
Member

konstin commented Oct 4, 2023

What about fmt_skip/decorators.py for the tests?

@dhruvmanila dhruvmanila enabled auto-merge (squash) October 4, 2023 07:47
@dhruvmanila dhruvmanila merged commit a1509df into main Oct 4, 2023
@dhruvmanila dhruvmanila deleted the dhruv/start-location branch October 4, 2023 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working formatter Related to the formatter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic when formatting file xpected the keyword token Def but found the token SimpleToken { kind: At, range: 46..47 } instead

3 participants