Skip to content

Commit cbbe552

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

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:
@@ -293,11 +290,7 @@ def write_report(self, stream_or_writer): # pragma: no cover
293290
Output stream or writer.
294291
"""
295292
# Warn the user that this method is deprecated and will be removed
296-
warnings.warn(
297-
deprecation_message(
298-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
299-
)
300-
)
293+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
301294

302295
# Check input writer/stream type
303296
if isinstance(stream_or_writer, io.IOBase):
@@ -774,11 +767,7 @@ def write_report(self, writer): # pragma: no cover
774767
Output writer.
775768
"""
776769
# Warn the user that this method is deprecated and will be removed
777-
warnings.warn(
778-
deprecation_message(
779-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
780-
)
781-
)
770+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
782771

783772
# Write header
784773
writer.writeln("Report\tPreparation")
@@ -1165,11 +1154,7 @@ def write_report(self, writer): # pragma: no cover
11651154
Output writer.
11661155
"""
11671156
# Warn the user that this method is deprecated and will be removed
1168-
warnings.warn(
1169-
deprecation_message(
1170-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
1171-
)
1172-
)
1157+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
11731158

11741159
# Write header
11751160
writer.writeln("Report\tBivariate preparation")
@@ -1406,11 +1391,7 @@ def write_report(self, writer): # pragma: no cover
14061391
Output writer.
14071392
"""
14081393
# Warn the user that this method is deprecated and will be removed
1409-
warnings.warn(
1410-
deprecation_message(
1411-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
1412-
)
1413-
)
1394+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
14141395

14151396
# Write header
14161397
writer.writeln("Report\tModeling")
@@ -1843,11 +1824,7 @@ def write_report(self, writer): # pragma: no cover
18431824
Output writer object.
18441825
"""
18451826
# Warn the user that this method is deprecated and will be removed
1846-
warnings.warn(
1847-
deprecation_message(
1848-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
1849-
)
1850-
)
1827+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
18511828

18521829
# Write report header
18531830
writer.write("Report\t")
@@ -2215,9 +2192,7 @@ def write_report_header_line(self, writer): # pragma: no cover
22152192
"""
22162193
# Warn the user that this method is deprecated and will be removed
22172194
warnings.warn(
2218-
deprecation_message(
2219-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2220-
)
2195+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
22212196
)
22222197

22232198
# Write report header
@@ -2255,11 +2230,7 @@ def write_report_line(self, writer): # pragma: no cover
22552230
Output writer.
22562231
"""
22572232
# Warn the user that this method is deprecated and will be removed
2258-
warnings.warn(
2259-
deprecation_message(
2260-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2261-
)
2262-
)
2233+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
22632234

22642235
# Write common attributes
22652236
writer.write(f"{self.rank}\t")
@@ -2333,11 +2304,7 @@ def write_report_details(self, writer): # pragma: no cover
23332304
Output writer.
23342305
"""
23352306
# Warn the user that this method is deprecated and will be removed
2336-
warnings.warn(
2337-
deprecation_message(
2338-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2339-
)
2340-
)
2307+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
23412308

23422309
# Write report if detailed report is available
23432310
if self.is_detailed():
@@ -2534,9 +2501,7 @@ def write_report_header_line(self, writer): # pragma: no cover
25342501
"""
25352502
# Warn the user that this method is deprecated and will be removed
25362503
warnings.warn(
2537-
deprecation_message(
2538-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2539-
)
2504+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
25402505
)
25412506

25422507
# Write identifier column names
@@ -2579,11 +2544,7 @@ def write_report_line(self, writer): # pragma: no cover
25792544
Output writer.
25802545
"""
25812546
# Warn the user that this method is deprecated and will be removed
2582-
warnings.warn(
2583-
deprecation_message(
2584-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2585-
)
2586-
)
2547+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
25872548

25882549
# Write identifier attributes
25892550
writer.write(f"{self.rank}\t")
@@ -2625,11 +2586,7 @@ def write_report_details(self, writer): # pragma: no cover
26252586
Output writer.
26262587
"""
26272588
# Warn the user that this method is deprecated and will be removed
2628-
warnings.warn(
2629-
deprecation_message(
2630-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
2631-
)
2632-
)
2589+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
26332590

26342591
# Write report if detailed report is available
26352592
if self.is_detailed():
@@ -3209,11 +3166,7 @@ def write_report(self, writer): # pragma: no cover
32093166
Output writer.
32103167
"""
32113168
# Warn the user that this method is deprecated and will be removed
3212-
warnings.warn(
3213-
deprecation_message(
3214-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3215-
)
3216-
)
3169+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
32173170

32183171
# Write data grid type
32193172
writer.write("Data grid\t")
@@ -3451,11 +3404,7 @@ def write_report(self, writer): # pragma: no cover
34513404
Output writer.
34523405
"""
34533406
# Warn the user that this method is deprecated and will be removed
3454-
warnings.warn(
3455-
deprecation_message(
3456-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3457-
)
3458-
)
3407+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
34593408

34603409
# Write report
34613410
writer.write(f"{self.variable}\t")
@@ -3567,11 +3516,7 @@ def write_report_line(self, writer): # pragma: no cover
35673516
Output writer.
35683517
"""
35693518
# Warn the user that this method is deprecated and will be removed
3570-
warnings.warn(
3571-
deprecation_message(
3572-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3573-
)
3574-
)
3519+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
35753520

35763521
# Write part label
35773522
writer.write(str(self))
@@ -3643,11 +3588,7 @@ def write_report_line(self, writer): # pragma: no cover
36433588
Output writer.
36443589
"""
36453590
# Warn the user that this method is deprecated and will be removed
3646-
warnings.warn(
3647-
deprecation_message(
3648-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3649-
)
3650-
)
3591+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
36513592

36523593
# Write object value
36533594
writer.writeln(str(self))
@@ -3723,11 +3664,7 @@ def write_report_line(self, writer): # pragma: no cover
37233664
Output writer.
37243665
"""
37253666
# Warn the user that this method is deprecated and will be removed
3726-
warnings.warn(
3727-
deprecation_message(
3728-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3729-
)
3730-
)
3667+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
37313668

37323669
# Write part label
37333670
writer.write(str(self))
@@ -3872,9 +3809,7 @@ def write_report_header_line(self, writer): # pragma: no cover
38723809
"""
38733810
# Warn the user that this method is deprecated and will be removed
38743811
warnings.warn(
3875-
deprecation_message(
3876-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3877-
)
3812+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
38783813
)
38793814

38803815
# Write report header line
@@ -3898,11 +3833,7 @@ def write_report_line(self, writer): # pragma: no cover
38983833
Output writer.
38993834
"""
39003835
# Warn the user that this method is deprecated and will be removed
3901-
warnings.warn(
3902-
deprecation_message(
3903-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3904-
)
3905-
)
3836+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
39063837

39073838
# Write report line
39083839
writer.write(f"{self.rank}\t")
@@ -3925,11 +3856,7 @@ def write_report_details(self, writer): # pragma: no cover
39253856
Output writer.
39263857
"""
39273858
# Warn the user that this method is deprecated and will be removed
3928-
warnings.warn(
3929-
deprecation_message(
3930-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
3931-
)
3932-
)
3859+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
39333860

39343861
# Write detailed report header if available
39353862
if self.is_detailed():
@@ -4019,9 +3946,7 @@ def write_report_header_line(self, writer): # pragma: no cover
40193946
"""
40203947
# Warn the user that this method is deprecated and will be removed
40213948
warnings.warn(
4022-
deprecation_message(
4023-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4024-
)
3949+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
40253950
)
40263951

40273952
# Write report header
@@ -4047,11 +3972,7 @@ def write_report_line(self, writer): # pragma: no cover
40473972
Output writer.
40483973
"""
40493974
# Warn the user that this method is deprecated and will be removed
4050-
warnings.warn(
4051-
deprecation_message(
4052-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4053-
)
4054-
)
3975+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
40553976

40563977
# Write report line
40573978
writer.write(f"{self.prepared_name}\t")
@@ -4279,9 +4200,7 @@ def write_report_header_line(self, writer): # pragma: no cover
42794200
"""
42804201
# Warn the user that this method is deprecated and will be removed
42814202
warnings.warn(
4282-
deprecation_message(
4283-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4284-
)
4203+
deprecation_message("write_report_header_line", "12.0.0", "to_dict")
42854204
)
42864205

42874206
# Write report header
@@ -4315,11 +4234,7 @@ def write_report_line(self, writer): # pragma: no cover
43154234
Output writer.
43164235
"""
43174236
# Warn the user that this method is deprecated and will be removed
4318-
warnings.warn(
4319-
deprecation_message(
4320-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4321-
)
4322-
)
4237+
warnings.warn(deprecation_message("write_report_line", "12.0.0", "to_dict"))
43234238

43244239
# Write report line
43254240
writer.write(f"{self.rank}\t")
@@ -4344,11 +4259,7 @@ def write_report_details(self, writer): # pragma: no cover
43444259
Output writer.
43454260
"""
43464261
# Warn the user that this method is deprecated and will be removed
4347-
warnings.warn(
4348-
deprecation_message(
4349-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4350-
)
4351-
)
4262+
warnings.warn(deprecation_message("write_report_details", "12.0.0", "to_dict"))
43524263

43534264
# Write detailed report if available
43544265
if self.is_detailed():
@@ -4421,11 +4332,7 @@ def write_report(self, writer): # pragma: no cover
44214332
Output writer.
44224333
"""
44234334
# Warn the user that this method is deprecated and will be removed
4424-
warnings.warn(
4425-
deprecation_message(
4426-
inspect.currentframe().f_code.co_name, "12.0.0", "to_dict"
4427-
)
4428-
)
4335+
warnings.warn(deprecation_message("write_report", "12.0.0", "to_dict"))
44294336

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

0 commit comments

Comments
 (0)