Skip to content

Commit 6bd29ce

Browse files
committed
Use plain method names in deprecation warnings for more code readability
1 parent b0b1dc1 commit 6bd29ce

File tree

2 files changed

+48
-212
lines changed

2 files changed

+48
-212
lines changed

khiops/core/analysis_results.py

Lines changed: 26 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
module look at their ``to_dict`` methods which write Python dictionaries in the
8484
same format as the Khiops JSON reports.
8585
"""
86-
import inspect
8786
import io
8887
import warnings
8988

@@ -242,9 +241,7 @@ def write_report_file(self, report_file_path): # pragma: no cover
242241
Path of the output TSV report file.
243242
"""
244243
# Warn the user that this method is deprecated and will be removed
245-
warnings.warn(
246-
deprecation_message(inspect.currentframe().f_code.co_name, "12.0.0")
247-
)
244+
warnings.warn(deprecation_message("write_report_file", "12.0.0"))
248245

249246
# Write report to file
250247
with open(report_file_path, "wb") as report_file:
@@ -295,11 +292,7 @@ def write_report(self, stream_or_writer): # pragma: no cover
295292
Output stream or writer.
296293
"""
297294
# Warn the user that this method is deprecated and will be removed
298-
warnings.warn(
299-
deprecation_message(
300-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
301-
)
302-
)
295+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
303296

304297
# Check input writer/stream type
305298
if isinstance(stream_or_writer, io.IOBase):
@@ -754,11 +747,7 @@ def write_report(self, writer): # pragma: no cover
754747
Output writer.
755748
"""
756749
# Warn the user that this method is deprecated and will be removed
757-
warnings.warn(
758-
deprecation_message(
759-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
760-
)
761-
)
750+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
762751

763752
# Write header
764753
writer.writeln("Report\tPreparation")
@@ -1146,11 +1135,7 @@ def write_report(self, writer): # pragma: no cover
11461135
Output writer.
11471136
"""
11481137
# Warn the user that this method is deprecated and will be removed
1149-
warnings.warn(
1150-
deprecation_message(
1151-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
1152-
)
1153-
)
1138+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
11541139

11551140
# Write header
11561141
writer.writeln("Report\tBivariate preparation")
@@ -1388,11 +1373,7 @@ def write_report(self, writer): # pragma: no cover
13881373
Output writer.
13891374
"""
13901375
# Warn the user that this method is deprecated and will be removed
1391-
warnings.warn(
1392-
deprecation_message(
1393-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
1394-
)
1395-
)
1376+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
13961377

13971378
# Write header
13981379
writer.writeln("Report\tModeling")
@@ -1826,11 +1807,7 @@ def write_report(self, writer): # pragma: no cover
18261807
Output writer object.
18271808
"""
18281809
# Warn the user that this method is deprecated and will be removed
1829-
warnings.warn(
1830-
deprecation_message(
1831-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
1832-
)
1833-
)
1810+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
18341811

18351812
# Write report header
18361813
writer.write("Report\t")
@@ -2199,9 +2176,7 @@ def write_report_header_line(self, writer): # pragma: no cover
21992176
"""
22002177
# Warn the user that this method is deprecated and will be removed
22012178
warnings.warn(
2202-
deprecation_message(
2203-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2204-
)
2179+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
22052180
)
22062181

22072182
# Write report header
@@ -2239,11 +2214,7 @@ def write_report_line(self, writer): # pragma: no cover
22392214
Output writer.
22402215
"""
22412216
# Warn the user that this method is deprecated and will be removed
2242-
warnings.warn(
2243-
deprecation_message(
2244-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2245-
)
2246-
)
2217+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
22472218

22482219
# Write common attributes
22492220
writer.write(f"{self.rank}\t")
@@ -2317,11 +2288,7 @@ def write_report_details(self, writer): # pragma: no cover
23172288
Output writer.
23182289
"""
23192290
# Warn the user that this method is deprecated and will be removed
2320-
warnings.warn(
2321-
deprecation_message(
2322-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2323-
)
2324-
)
2291+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
23252292

23262293
# Write report if detailed report is available
23272294
if self.is_detailed():
@@ -2519,9 +2486,7 @@ def write_report_header_line(self, writer): # pragma: no cover
25192486
"""
25202487
# Warn the user that this method is deprecated and will be removed
25212488
warnings.warn(
2522-
deprecation_message(
2523-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2524-
)
2489+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
25252490
)
25262491

25272492
# Write identifier column names
@@ -2564,11 +2529,7 @@ def write_report_line(self, writer): # pragma: no cover
25642529
Output writer.
25652530
"""
25662531
# Warn the user that this method is deprecated and will be removed
2567-
warnings.warn(
2568-
deprecation_message(
2569-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2570-
)
2571-
)
2532+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
25722533

25732534
# Write identifier attributes
25742535
writer.write(f"{self.rank}\t")
@@ -2610,11 +2571,7 @@ def write_report_details(self, writer): # pragma: no cover
26102571
Output writer.
26112572
"""
26122573
# Warn the user that this method is deprecated and will be removed
2613-
warnings.warn(
2614-
deprecation_message(
2615-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2616-
)
2617-
)
2574+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
26182575

26192576
# Write report if detailed report is available
26202577
if self.is_detailed():
@@ -3200,11 +3157,7 @@ def write_report(self, writer): # pragma: no cover
32003157
Output writer.
32013158
"""
32023159
# Warn the user that this method is deprecated and will be removed
3203-
warnings.warn(
3204-
deprecation_message(
3205-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3206-
)
3207-
)
3160+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
32083161

32093162
# Write data grid type
32103163
writer.write("Data grid\t")
@@ -3443,11 +3396,7 @@ def write_report(self, writer): # pragma: no cover
34433396
Output writer.
34443397
"""
34453398
# Warn the user that this method is deprecated and will be removed
3446-
warnings.warn(
3447-
deprecation_message(
3448-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3449-
)
3450-
)
3399+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
34513400

34523401
# Write report
34533402
writer.write(f"{self.variable}\t")
@@ -3560,11 +3509,7 @@ def write_report_line(self, writer): # pragma: no cover
35603509
Output writer.
35613510
"""
35623511
# Warn the user that this method is deprecated and will be removed
3563-
warnings.warn(
3564-
deprecation_message(
3565-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3566-
)
3567-
)
3512+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
35683513

35693514
# Write part label
35703515
writer.write(str(self))
@@ -3637,11 +3582,7 @@ def write_report_line(self, writer): # pragma: no cover
36373582
Output writer.
36383583
"""
36393584
# Warn the user that this method is deprecated and will be removed
3640-
warnings.warn(
3641-
deprecation_message(
3642-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3643-
)
3644-
)
3585+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
36453586

36463587
# Write object value
36473588
writer.writeln(str(self))
@@ -3718,11 +3659,7 @@ def write_report_line(self, writer): # pragma: no cover
37183659
Output writer.
37193660
"""
37203661
# Warn the user that this method is deprecated and will be removed
3721-
warnings.warn(
3722-
deprecation_message(
3723-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3724-
)
3725-
)
3662+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
37263663

37273664
# Write part label
37283665
writer.write(str(self))
@@ -3868,9 +3805,7 @@ def write_report_header_line(self, writer): # pragma: no cover
38683805
"""
38693806
# Warn the user that this method is deprecated and will be removed
38703807
warnings.warn(
3871-
deprecation_message(
3872-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3873-
)
3808+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
38743809
)
38753810

38763811
# Write report header line
@@ -3894,11 +3829,7 @@ def write_report_line(self, writer): # pragma: no cover
38943829
Output writer.
38953830
"""
38963831
# Warn the user that this method is deprecated and will be removed
3897-
warnings.warn(
3898-
deprecation_message(
3899-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3900-
)
3901-
)
3832+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
39023833

39033834
# Write report line
39043835
writer.write(f"{self.rank}\t")
@@ -3921,11 +3852,7 @@ def write_report_details(self, writer): # pragma: no cover
39213852
Output writer.
39223853
"""
39233854
# Warn the user that this method is deprecated and will be removed
3924-
warnings.warn(
3925-
deprecation_message(
3926-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3927-
)
3928-
)
3855+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
39293856

39303857
# Write detailed report header if available
39313858
if self.is_detailed():
@@ -4016,9 +3943,7 @@ def write_report_header_line(self, writer): # pragma: no cover
40163943
"""
40173944
# Warn the user that this method is deprecated and will be removed
40183945
warnings.warn(
4019-
deprecation_message(
4020-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4021-
)
3946+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
40223947
)
40233948

40243949
# Write report header
@@ -4044,11 +3969,7 @@ def write_report_line(self, writer): # pragma: no cover
40443969
Output writer.
40453970
"""
40463971
# Warn the user that this method is deprecated and will be removed
4047-
warnings.warn(
4048-
deprecation_message(
4049-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4050-
)
4051-
)
3972+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
40523973

40533974
# Write report line
40543975
writer.write(f"{self.prepared_name}\t")
@@ -4277,9 +4198,7 @@ def write_report_header_line(self, writer): # pragma: no cover
42774198
"""
42784199
# Warn the user that this method is deprecated and will be removed
42794200
warnings.warn(
4280-
deprecation_message(
4281-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4282-
)
4201+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
42834202
)
42844203

42854204
# Write report header
@@ -4313,11 +4232,7 @@ def write_report_line(self, writer): # pragma: no cover
43134232
Output writer.
43144233
"""
43154234
# Warn the user that this method is deprecated and will be removed
4316-
warnings.warn(
4317-
deprecation_message(
4318-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4319-
)
4320-
)
4235+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
43214236

43224237
# Write report line
43234238
writer.write(f"{self.rank}\t")
@@ -4342,11 +4257,7 @@ def write_report_details(self, writer): # pragma: no cover
43424257
Output writer.
43434258
"""
43444259
# Warn the user that this method is deprecated and will be removed
4345-
warnings.warn(
4346-
deprecation_message(
4347-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4348-
)
4349-
)
4260+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
43504261

43514262
# Write detailed report if available
43524263
if self.is_detailed():
@@ -4420,11 +4331,7 @@ def write_report(self, writer): # pragma: no cover
44204331
Output writer.
44214332
"""
44224333
# Warn the user that this method is deprecated and will be removed
4423-
warnings.warn(
4424-
deprecation_message(
4425-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4426-
)
4427-
)
4334+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
44284335

44294336
# Write header
44304337
writer.writeln("Confusion matrix")

0 commit comments

Comments
 (0)