Strip form feeds from indent passed to dedent_to#24381
Merged
dylwil3 merged 3 commits intoastral-sh:mainfrom Apr 3, 2026
Merged
Strip form feeds from indent passed to dedent_to#24381dylwil3 merged 3 commits intoastral-sh:mainfrom
dedent_to#24381dylwil3 merged 3 commits intoastral-sh:mainfrom
Conversation
|
carljm
added a commit
that referenced
this pull request
Apr 3, 2026
* main: Document adding fixes in CONTRIBUTING.md (#24393) Sort formatter diagnostics in snapshots (#24375) [`pyupgrade`] Fix panic caused by handling of octals in `UP012` (#24390) Upgrade to nix v0.31.2 (#24385) Strip form feeds from indent passed to `dedent_to` (#24381) add recent move of the `deferred` submodule to `.git-blame-ignore-revs` (#24379) [ty] Fix extra_items TypedDict tests (#24367) [ty] Use `infer_type_expression` for validating PEP-613 type aliases (#24370) [`flake8-simplify`] Make the fix for `collapsible-if` (`SIM102`) safe in `preview` (#24371) [ty] Validate TypedDict fields when subclassing (#24338) [ty] pass type context to sequence literals in binary operations (#24197) Add release environment to notify-dependents job (#24372) Bump 0.15.9 (#24369) [ty] Move the `deferred` submodule inside `infer/builder` (#24368) [ty] Infer the `extra_items` keyword argument to class-based TypedDicts as an annotation expression (#24362) [ty] Validate type qualifiers in functional TypedDict fields and the `extra_items` keyword to functional TypedDicts (#24360)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When adjusting "simple" indentation in the formation of edits, we attempt to dedent manually rather than deferring to LibCST. To do so we must provide a desired indentation, in the form of a string. We often grab this from source code by slicing the text in a range beginning at the start of a line.
In Python, the start of a line may contain form feeds but these do not contribute to the indentation. In this PR, we strip the provided indentation of its leading form feeds in order to get the correct indentation amount for use in
dedent_to. This avoids the introduction of a syntax error in the editadjust_indentation.Note: We could try to stay closer to the user's intent by prepending the form feed prefix of the provided indentation everywhere in the resulting edit, but that seems a little unwieldy and this is a bit of an edge case anyway.
Closes #24373