Skip to content

Add PreviewMode option to formatter#7217

Merged
MichaReiser merged 2 commits intomainfrom
add-preview-flag-to-formatter
Sep 8, 2023
Merged

Add PreviewMode option to formatter#7217
MichaReiser merged 2 commits intomainfrom
add-preview-flag-to-formatter

Conversation

@MichaReiser
Copy link
Member

Summary

This PR adds the --preview and --no-preview options to the format command (hidden) and passes it through to the formatte.

Test Plan

I added the dbg(f.options().preview()) statement in FormatNodeRule::fmt and verified that the option gets correctly passed to the formatter.

@MichaReiser MichaReiser added cli Related to the command-line interface formatter Related to the formatter labels Sep 7, 2023
@MichaReiser MichaReiser force-pushed the add-preview-flag-to-formatter branch from c1cc7cd to 193a218 Compare September 7, 2023 11:09
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 7, 2023

CodSpeed Performance Report

Merging #7217 will degrade performances by 2.54%

Comparing add-preview-flag-to-formatter (65c5853) with main (41f0aad)

Summary

❌ 1 regressions
✅ 24 untouched benchmarks

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

Benchmarks breakdown

Benchmark main add-preview-flag-to-formatter Change
linter/all-rules[numpy/ctypeslib.py] 32.6 ms 33.5 ms -2.54%

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@MichaReiser MichaReiser force-pushed the binary-like-fstring-support branch from a4b4a31 to 1d0d8cc Compare September 8, 2023 06:38
@MichaReiser MichaReiser force-pushed the add-preview-flag-to-formatter branch from 193a218 to 0682684 Compare September 8, 2023 06:40
@MichaReiser MichaReiser force-pushed the binary-like-fstring-support branch from 1d0d8cc to 3e5f82e Compare September 8, 2023 06:57
@MichaReiser MichaReiser force-pushed the add-preview-flag-to-formatter branch from f61f478 to e601118 Compare September 8, 2023 06:57
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is preview mode a global only flag or can it also be hierarchical?

@MichaReiser
Copy link
Member Author

Is preview mode a global only flag or can it also be hierarchical?

I would expect it to be hierarchical the same way as any other configuration option.

CC: @zanieb

Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to approve

@charliermarsh
Copy link
Member

IMO it should match the behavior of other settings (and I assume it will by default based on the implementation): hierarchical, but providing it on the command-line overrides it for all files.

@MichaReiser MichaReiser force-pushed the binary-like-fstring-support branch 2 times, most recently from e9fe660 to 259ac02 Compare September 8, 2023 09:26
@MichaReiser MichaReiser force-pushed the add-preview-flag-to-formatter branch from e601118 to 814f4dc Compare September 8, 2023 09:28
@MichaReiser MichaReiser force-pushed the binary-like-fstring-support branch from 259ac02 to 14c775c Compare September 8, 2023 09:33
Base automatically changed from binary-like-fstring-support to main September 8, 2023 09:48
@MichaReiser
Copy link
Member Author

MichaReiser commented Sep 8, 2023

Merge Activity

  • Sep 8, 5:50 AM: Graphite rebased this pull request as part of a merge.
  • Sep 8, 6:04 AM: @MichaReiser merged this pull request with Graphite.

@MichaReiser MichaReiser force-pushed the add-preview-flag-to-formatter branch from 814f4dc to 65c5853 Compare September 8, 2023 09:50
@MichaReiser MichaReiser merged commit 47a253f into main Sep 8, 2023
@MichaReiser MichaReiser deleted the add-preview-flag-to-formatter branch September 8, 2023 10:04
@zanieb zanieb added the preview Related to preview mode features label Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the command-line interface formatter Related to the formatter preview Related to preview mode features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce new PreviewStyle enum with Enabled and Disabled variants and add it to PyFormatOptions

4 participants