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

Add PreviewMode option to formatter #7217

Merged
merged 2 commits into from
Sep 8, 2023
Merged

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
@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.

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
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 merged commit 47a253f into main Sep 8, 2023
15 of 16 checks passed
@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