10 """ |
10 """ |
11 |
11 |
12 from PyQt6.QtCore import QCoreApplication |
12 from PyQt6.QtCore import QCoreApplication |
13 |
13 |
14 _loggingMessages = { |
14 _loggingMessages = { |
15 ## Logging format |
15 ## Logging |
16 "L101": QCoreApplication.translate( |
16 "L101": QCoreApplication.translate( |
17 "LoggingChecker", |
17 "LoggingChecker", |
18 "logging statement uses string.format()", |
18 "use logging.getLogger() to instantiate loggers", |
19 ), |
19 ), |
20 "L102": QCoreApplication.translate( |
20 "L102": QCoreApplication.translate( |
21 "LoggingChecker", |
21 "LoggingChecker", |
22 "logging statement uses '%'", # __IGNORE_WARNING_M601__ |
22 "use '__name__' with getLogger()", |
23 ), |
23 ), |
24 "L103": QCoreApplication.translate( |
24 "L103": QCoreApplication.translate( |
25 "LoggingChecker", |
25 "LoggingChecker", |
26 "logging statement uses '+'", |
26 "extra key {0} clashes with LogRecord attribute", |
27 ), |
27 ), |
28 "L104": QCoreApplication.translate( |
28 "L104": QCoreApplication.translate( |
29 "LoggingChecker", |
29 "LoggingChecker", |
30 "logging statement uses f-string", |
30 "avoid exception() outside of exception handlers", |
|
31 ), |
|
32 "L105": QCoreApplication.translate( |
|
33 "LoggingChecker", |
|
34 ".exception(...) should be used instead of .error(..., exc_info=True)", |
|
35 ), |
|
36 "L106": QCoreApplication.translate( |
|
37 "LoggingChecker", |
|
38 "redundant exc_info argument for exception() should be removed", |
|
39 ), |
|
40 "L107": QCoreApplication.translate( |
|
41 "LoggingChecker", |
|
42 "use error() instead of exception() with exc_info=False", |
|
43 ), |
|
44 "L108": QCoreApplication.translate( |
|
45 "LoggingChecker", |
|
46 "warn() is deprecated, use warning() instead", |
|
47 ), |
|
48 "L109": QCoreApplication.translate( |
|
49 "LoggingChecker", |
|
50 "WARN is undocumented, use WARNING instead", |
31 ), |
51 ), |
32 "L110": QCoreApplication.translate( |
52 "L110": QCoreApplication.translate( |
33 "LoggingChecker", |
53 "LoggingChecker", |
34 "logging statement uses 'warn' instead of 'warning'", |
54 "exception() does not take an exception", |
35 ), |
55 ), |
36 "L121": QCoreApplication.translate( |
56 "L111a": QCoreApplication.translate( |
37 "LoggingChecker", |
57 "LoggingChecker", |
38 "logging statement uses an extra field that clashes with a LogRecord field:" |
58 "avoid pre-formatting log messages using f-string", |
39 " {0}", |
|
40 ), |
59 ), |
41 "L130": QCoreApplication.translate( |
60 "L111b": QCoreApplication.translate( |
42 "LoggingChecker", |
61 "LoggingChecker", |
43 "logging statement uses exception in arguments", |
62 "avoid pre-formatting log messages using string.format()", |
44 ), |
63 ), |
45 "L131": QCoreApplication.translate( |
64 "L111c": QCoreApplication.translate( |
46 "LoggingChecker", |
65 "LoggingChecker", |
47 "logging: .exception(...) should be used instead of .error(..., exc_info=True)", |
66 "avoid pre-formatting log messages using '%'", # noqa: M601 |
48 ), |
67 ), |
49 "L132": QCoreApplication.translate( |
68 "L111d": QCoreApplication.translate( |
50 "LoggingChecker", |
69 "LoggingChecker", |
51 "logging statement has redundant exc_info", |
70 "avoid pre-formatting log messages using '+'", |
|
71 ), |
|
72 "L112": QCoreApplication.translate( |
|
73 "LoggingChecker", |
|
74 "formatting error: {0} {1} placeholder(s) but {2} argument(s)", |
|
75 ), |
|
76 "L113a": QCoreApplication.translate( |
|
77 "LoggingChecker", |
|
78 "formatting error: missing key(s): {0}", |
|
79 ), |
|
80 "L113b": QCoreApplication.translate( |
|
81 "LoggingChecker", |
|
82 "formatting error: unreferenced key(s): {0}", |
|
83 ), |
|
84 "L114": QCoreApplication.translate( |
|
85 "LoggingChecker", |
|
86 "avoid exc_info=True outside of exception handlers", |
52 ), |
87 ), |
53 } |
88 } |
54 |
89 |
55 _loggingMessagesSampleArgs = { |
90 _loggingMessagesSampleArgs = { |
56 "L121": ["pathname"], |
91 ## Logging |
|
92 "L103": ["'pathname'"], |
|
93 "L112": [3, "'%'", 2], # noqa: M601 |
|
94 "L113a": ["'foo', 'bar'"], |
|
95 "L113b": ["'foo', 'bar'"], |
57 } |
96 } |