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

Use ruff line-length in format_dev #6870

Merged
merged 2 commits into from
Sep 5, 2023
Merged

Use ruff line-length in format_dev #6870

merged 2 commits into from
Sep 5, 2023

Conversation

konstin
Copy link
Member

@konstin konstin commented Aug 25, 2023

Summary Use the [ruff] config line length setting in format_dev. This aligns it with ruff format (originally, this was the prototype for ruff format, but now ruff format works and we instead need to keep format_dev consistent).

@konstin
Copy link
Member Author

konstin commented Aug 25, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 2023

PR Check Results

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      4.1±0.02ms    10.0 MB/sec    1.00      4.1±0.01ms    10.0 MB/sec
formatter/numpy/ctypeslib.py               1.00    854.0±2.40µs    19.5 MB/sec    1.00    854.3±2.49µs    19.5 MB/sec
formatter/numpy/globals.py                 1.00     84.1±0.34µs    35.1 MB/sec    1.01     84.5±0.37µs    34.9 MB/sec
formatter/pydantic/types.py                1.01   1684.9±8.49µs    15.1 MB/sec    1.00   1671.8±7.57µs    15.3 MB/sec
linter/all-rules/large/dataset.py          1.00     10.0±0.04ms     4.1 MB/sec    1.01     10.1±0.06ms     4.0 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      2.7±0.00ms     6.2 MB/sec    1.00      2.7±0.01ms     6.2 MB/sec
linter/all-rules/numpy/globals.py          1.00    377.7±0.54µs     7.8 MB/sec    1.00    376.5±0.52µs     7.8 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.2±0.03ms     4.9 MB/sec    1.00      5.2±0.04ms     4.9 MB/sec
linter/default-rules/large/dataset.py      1.01      5.3±0.01ms     7.6 MB/sec    1.00      5.3±0.01ms     7.7 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1178.6±17.92µs    14.1 MB/sec    1.00   1175.7±8.25µs    14.2 MB/sec
linter/default-rules/numpy/globals.py      1.01    139.5±4.90µs    21.1 MB/sec    1.00    137.7±1.86µs    21.4 MB/sec
linter/default-rules/pydantic/types.py     1.00      2.4±0.01ms    10.6 MB/sec    1.00      2.4±0.03ms    10.6 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      5.5±0.17ms     7.4 MB/sec    1.04      5.7±0.20ms     7.1 MB/sec
formatter/numpy/ctypeslib.py               1.00  1120.0±47.17µs    14.9 MB/sec    1.04  1169.5±30.49µs    14.2 MB/sec
formatter/numpy/globals.py                 1.00   112.2±10.25µs    26.3 MB/sec    1.02    114.7±5.31µs    25.7 MB/sec
formatter/pydantic/types.py                1.00      2.3±0.12ms    11.2 MB/sec    1.03      2.4±0.07ms    10.8 MB/sec
linter/all-rules/large/dataset.py          1.03     15.3±0.48ms     2.7 MB/sec    1.00     14.9±0.39ms     2.7 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      4.1±0.11ms     4.0 MB/sec    1.00      4.1±0.09ms     4.1 MB/sec
linter/all-rules/numpy/globals.py          1.02   525.4±25.44µs     5.6 MB/sec    1.00   512.9±12.32µs     5.8 MB/sec
linter/all-rules/pydantic/types.py         1.01      7.8±0.22ms     3.3 MB/sec    1.00      7.7±0.16ms     3.3 MB/sec
linter/default-rules/large/dataset.py      1.04      8.5±0.52ms     4.8 MB/sec    1.00      8.2±0.11ms     5.0 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1775.3±50.53µs     9.4 MB/sec    1.00  1783.1±45.47µs     9.3 MB/sec
linter/default-rules/numpy/globals.py      1.00   205.5±10.57µs    14.4 MB/sec    1.02    210.0±5.39µs    14.1 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.7±0.10ms     6.9 MB/sec    1.01      3.7±0.07ms     6.9 MB/sec

@konstin konstin marked this pull request as ready for review August 25, 2023 13:32
@konstin konstin added the formatter Related to the formatter label Aug 25, 2023

let settings = resolver.resolve(&path, pyproject_config);
// That's a bad way of doing this but it's not worth doing something better for format_dev
if settings.line_length != LineLength::default() {
Copy link
Member

Choose a reason for hiding this comment

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

Is this because you're trying to see if it's not the default? Why can't we just use settings.line_length? Because it will be wrong for projects in the formatter CI that use Black but not Ruff?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, this only exists to have a (dummy) usage for the line length without breaking the formatter ecosystem checks

Copy link
Member

Choose a reason for hiding this comment

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

Should Settings.line_length be an Option<LineLength> if that's something we want to distinguish?

@konstin konstin requested review from MichaReiser and removed request for MichaReiser September 5, 2023 12:25
@konstin
Copy link
Member Author

konstin commented Sep 5, 2023

Please give this another look, this now only changes what's really needed for format_dev.

Comment on lines 554 to 555
let line_width = LineWidth::try_from(settings.line_length.value())
.expect("Configured line length is too large for the formatter");
Copy link
Member Author

Choose a reason for hiding this comment

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

i still don't like this divergence

Copy link
Member

Choose a reason for hiding this comment

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

You can do LineWidth::from(NonZeroU16::from(line_length)))

Comment on lines 554 to 555
let line_width = LineWidth::try_from(settings.line_length.value())
.expect("Configured line length is too large for the formatter");
Copy link
Member

Choose a reason for hiding this comment

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

You can do LineWidth::from(NonZeroU16::from(line_length)))

@konstin konstin merged commit 5a95eda into main Sep 5, 2023
16 checks passed
@konstin konstin deleted the line-length-in-format-dev branch September 5, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants