Skip to content

MNT Apply ruff/flake8-implicit-str-concat rules (ISC) #30695

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

Merged
merged 4 commits into from
Mar 18, 2025

Conversation

DimitriPapadopoulos
Copy link
Contributor

What does this implement/fix? Explain your changes.

Applying rule ISC001 merges split string literals — usually as a result of black unfolding a line.

As for rule ISC003, it may appear it doesn't improve readability in some cases. However, I see such cases as black formatting issues.

Any other comments?

Not sure these rules should be enforced in CI, because I'm not certain they're always compatible with black.

[doc skip]

@DimitriPapadopoulos DimitriPapadopoulos changed the title Isc MAINT Apply ruff/flake8-implicit-str-concat rules (ISC) Jan 21, 2025
Copy link

github-actions bot commented Jan 21, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: eff954f. Link to the linter CI: here

+ r"(([A-Za-z]+\-?)+)"
+ r"(MinVersion\| replace::)"
+ r"( [0-9]+\.[0-9]+(\.[0-9]+)?)"
r"(([A-Za-z]+\-?)+)"

Check failure

Code scanning / CodeQL

Inefficient regular expression High test

This part of the regular expression may cause exponential backtracking on strings starting with '.. |' and containing many repetitions of 'A'.
@DimitriPapadopoulos DimitriPapadopoulos changed the title MAINT Apply ruff/flake8-implicit-str-concat rules (ISC) MNT Apply ruff/flake8-implicit-str-concat rules (ISC) Jan 21, 2025
@DimitriPapadopoulos DimitriPapadopoulos force-pushed the ISC branch 2 times, most recently from 2613932 to 8fedcdf Compare March 11, 2025 14:07
@@ -116,7 +116,7 @@ def plot_results(ax1, ax2, estimator, X, y, title, plot_title=False):
[0.001, 1, 1000],
),
(
"Infinite mixture with a Dirichlet process\n prior and" r"$\gamma_0=$",
"Infinite mixture with a Dirichlet process\nprior and $\\gamma_0=$",
Copy link
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos Mar 11, 2025

Choose a reason for hiding this comment

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

This one's debatable.

Note I've also removed an extra space for consistency with previous estimator.

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

ISC001 Implicitly concatenated string literals on one line
ISC003 Explicitly concatenated string should be implicitly concatenated
Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Please avoid force pushing since it makes review harder. It's easier to have the whole history in the PR.

@adrinjalali
Copy link
Member

I've also wondered about switching to ruff formatter instead of black. One less tool to handle.

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Mar 18, 2025

Sure, I could switch to ruff format in a different PR.

EDIT: See #31015.

@adrinjalali
Copy link
Member

@Charlie-XIAO maybe you could have a look? Should be an easy review.

Copy link
Contributor

@Charlie-XIAO Charlie-XIAO left a comment

Choose a reason for hiding this comment

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

This LGTM, thanks! I think we do need to fix CodeQL though.

Inefficient regular expression

This part of the regular expression may cause exponential backtracking on strings starting with `.. |` and containing many repetitions of `A`.

Co-authored-by: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com>
This reverts commit 76b2c95.
@Charlie-XIAO Charlie-XIAO merged commit 5cdbbf1 into scikit-learn:main Mar 18, 2025
32 of 33 checks passed
@DimitriPapadopoulos DimitriPapadopoulos deleted the ISC branch March 18, 2025 20:01
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Mar 19, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Mar 19, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Mar 24, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Apr 15, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Apr 15, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
* black → ruff format (scikit-learn#31015)
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Apr 15, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
* black → ruff format (scikit-learn#31015)
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Apr 15, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
* black → ruff format (scikit-learn#31015)
DimitriPapadopoulos added a commit to DimitriPapadopoulos/scikit-learn that referenced this pull request Apr 15, 2025
* Enforce ruff rules (RUF) (scikit-learn#30694)
* Apply ruff/flake8-implicit-str-concat rules (ISC) (scikit-learn#30695)
* black → ruff format (scikit-learn#31015)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants