8000 MNT Apply ruff/flake8-implicit-str-concat rule ISC003 · scikit-learn/scikit-learn@039b8e5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 039b8e5

Browse files
MNT Apply ruff/flake8-implicit-str-concat rule ISC003
ISC003 Explicitly concatenated string should be implicitly concatenated
1 parent 302f73a commit 039b8e5

File tree

11 files changed

+37
-41
lines changed

11 files changed

+37
-41
lines changed

build_tools/get_comment.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ def get_step_message(log, start, end, title, message, details):
5656
return ""
5757
res = (
5858
"-----------------------------------------------\n"
59-
+ f"### {title}\n\n"
60-
+ message
61-
+ "\n\n"
59+
f"### {title}\n\n"
60+
f"{message}\n\n"
6261
)
6362
if details:
6463
res += (

examples/classification/plot_lda.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def generate_data(n_samples, n_features):
9898
plt.legend(loc="lower left")
9999
plt.ylim((0.65, 1.0))
100100
plt.suptitle(
101-
"LDA (Linear Discriminant Analysis) vs. "
102-
+ "\n"
103-
+ "LDA with Ledoit Wolf vs. "
104-
+ "\n"
105-
+ "LDA with OAS (1 discriminative feature)"
101+
"LDA (Linear Discriminant Analysis) vs."
102+
"\n"
103+
"LDA with Ledoit Wolf vs."
104+
"\n"
105+
"LDA with OAS (1 discriminative feature)"
106106
)
107107
plt.show()

examples/cluster/plot_cluster_comparison.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@
224224
warnings.filterwarnings(
225225
"ignore",
226226
message="the number of connected components of the "
227-
+ "connectivity matrix is [0-9]{1,2}"
228-
+ " > 1. Completing it to avoid stopping the tree early.",
227+
"connectivity matrix is [0-9]{1,2}"
228+
" > 1. Completing it to avoid stopping the tree early.",
229229
category=UserWarning,
230230
)
231231
warnings.filterwarnings(
232232
"ignore",
233233
message="Graph is not fully connected, spectral embedding"
234-
+ " may not work as expected.",
234+
" may not work as expected.",
235235
category=UserWarning,
236236
)
237237
algorithm.fit(X)

examples/cluster/plot_linkage_comparison.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@
123123
warnings.filterwarnings(
124124
"ignore",
125125
message="the number of connected components of the "
126-
+ "connectivity matrix is [0-9]{1,2}"
127-
+ " > 1. Completing it to avoid stopping the tree early.",
126+
"connectivity matrix is [0-9]{1,2}"
127+
" > 1. Completing it to avoid stopping the tree early.",
128128
category=UserWarning,
129129
)
130130
algorithm.fit(X)

examples/kernel_approximation/plot_scalable_poly_kernels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
}
144144
print(
145145
f"Linear SVM score on {n_components} PolynomialCountSketch "
146-
+ f"features: {ps_lsvm_score:.2f}%"
146+
f"features: {ps_lsvm_score:.2f}%"
147147
)
148148

149149
# %%

sklearn/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def _clone_parametrized(estimator, *, safe=True):
110110
if isinstance(estimator, type):
111111
raise TypeError(
112112
"Cannot clone object. "
113-
+ "You should provide an instance of "
114-
+ "scikit-learn estimator instead of a class."
113+
"You should provide an instance of "
114+
"scikit-learn estimator instead of a class."
115115
)
116116
else:
117117
raise TypeError(

sklearn/decomposition/_factor_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ def my_svd(X):
295295
else:
296296
warnings.warn(
297297
"FactorAnalysis did not converge."
298-
+ " You might want"
299-
+ " to increase the number of iterations.",
298+
" You might want"
299+
" to increase the number of iterations.",
300300
ConvergenceWarning,
301301
)
302302

sklearn/feature_selection/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ def _get_feature_importances(estimator, getter, transform_func=None, norm_order=
260260
else:
261261
raise ValueError(
262262
"Valid values for `transform_func` are "
263-
+ "None, 'norm' and 'square'. Those two "
264-
+ "transformation are only supported now"
263+
"None, 'norm' and 'square'. Those two "
264+
"transformation are only supported now"
265265
)
266266

267267
return importances

sklearn/tests/test_docstring_parameters_consistency.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
by support \(the number of true instances for each label\)\. This
7171
alters 'macro' to account for label imbalance; it can result in an
7272
F-score that is not between precision and recall\."""
73-
+ r"[\s\w]*\.*" # optionally match additional sentence
74-
+ r"""
73+
r"[\s\w]*\.*" # optionally match additional sentence
74+
r"""
7575
``'samples'``:
7676
Calculate metrics for each instance, and find their average \(only
7777
meaningful for multilabel classification where this differs from

sklearn/tests/test_min_dependencies_readme.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def test_min_dependencies_readme():
3333

3434
pattern = re.compile(
3535
r"(\.\. \|)"
36-
+ r"(([A-Za-z]+\-?)+)"
37-
+ r"(MinVersion\| replace::)"
38-
+ r"( [0-9]+\.[0-9]+(\.[0-9]+)?)"
36+
r"(([A-Za-z]+\-?)+)"
37+
r"(MinVersion\| replace::)"
38+
r"( [0-9]+\.[0-9]+(\.[0-9]+)?)"
3939
)
4040

4141
readme_path = Path(sklearn.__file__).parent.parent

sklearn/utils/tests/test_testing.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ def test_check_docstring_parameters():
443443
"+ ['a', 'b']",
444444
],
445445
[
446-
"In function: "
447-
+ "sklearn.utils.tests.test_testing.f_too_many_param_docstring",
446+
"In function: sklearn.utils.tests.test_testing.f_too_many_param_docstring",
448447
(
449448
"Parameters in function docstring have more items w.r.t. function"
450449
" signature, first extra item: c"
@@ -475,8 +474,7 @@ def test_check_docstring_parameters():
475474
"+ []",
476475
],
477476
[
478-
"In function: "
479-
+ f"sklearn.utils.tests.test_testing.{mock_meta_name}.predict",
477+
f"In function: sklearn.utils.tests.test_testing.{mock_meta_name}.predict",
480478
(
481479
"There's a parameter name mismatch in function docstring w.r.t."
482480
" function signature, at index 0 diff: 'X' != 'y'"
@@ -489,21 +487,20 @@ def test_check_docstring_parameters():
489487
],
490488
[
491489
"In function: "
492-
+ f"sklearn.utils.tests.test_testing.{mock_meta_name}."
493-
+ "predict_proba",
490+
f"sklearn.utils.tests.test_testing.{mock_meta_name}."
491+
"predict_proba",
494492
"potentially wrong underline length... ",
495493
"Parameters ",
496494
"--------- in ",
497495
],
498496
[
499-
"In function: "
500-
+ f"sklearn.utils.tests.test_testing.{mock_meta_name}.score",
497+
f"In function: sklearn.utils.tests.test_testing.{mock_meta_name}.score",
501498
"potentially wrong underline length... ",
502499
"Parameters ",
503500
"--------- in ",
504501
],
505502
[
506-
"In function: " + f"sklearn.utils.tests.test_testing.{mock_meta_name}.fit",
503+
f"In function: sklearn.utils.tests.test_testing.{mock_meta_name}.fit",
507504
(
508505
"Parameters in function docstring have less items w.r.t. function"
509506
" signature, first missing item: X"
@@ -788,13 +785,13 @@ def test_assert_docstring_consistency_descr_regex_pattern():
788785
# Check regex that matches full parameter descriptions
789786
regex_full = (
790787
r"The (set|group) " # match 'set' or 'group'
791-
+ r"of labels to (include|add) " # match 'include' or 'add'
792-
+ r"when `average \!\= 'binary'`, and (their|the) " # match 'their' or 'the'
793-
+ r"order if `average is None`\."
794-
+ r"[\s\w]*\.* " # optionally match additional sentence
795-
+ r"Labels present (on|in) " # match 'on' or 'in'
796-
+ r"(them|the) " # match 'them' or 'the'
797-
+ r"datas? can be excluded\." # match 'data' or 'datas'
788+
r"of labels to (include|add) " # match 'include' or 'add'
789+
r"when `average \!\= 'binary'`, and (their|the) " # match 'their' or 'the'
790+
r"order if `average is None`\."
791+
r"[\s\w]*\.* " # optionally match additional sentence
792+
r"Labels present (on|in) " # match 'on' or 'in'
793+
r"(them|the) " # match 'them' or 'the'
794+
r"datas? can be excluded\." # match 'data' or 'datas'
798795
)
799796

800797
assert_docstring_consistency(

0 commit comments

Comments
 (0)
0