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