11 from PyQt6.QtCore import QCoreApplication |
11 from PyQt6.QtCore import QCoreApplication |
12 |
12 |
13 __all__ = ["getTranslatedFlakesMessage"] |
13 __all__ = ["getTranslatedFlakesMessage"] |
14 |
14 |
15 _messages = { |
15 _messages = { |
16 'F01': QCoreApplication.translate( |
16 "F01": QCoreApplication.translate("pyFlakes", "{0!r} imported but unused."), |
17 'pyFlakes', |
17 "F02": QCoreApplication.translate( |
18 '{0!r} imported but unused.'), |
18 "pyFlakes", "Redefinition of unused {0!r} from line {1!r}." |
19 'F02': QCoreApplication.translate( |
19 ), |
20 'pyFlakes', |
20 "F03": QCoreApplication.translate( |
21 'Redefinition of unused {0!r} from line {1!r}.'), |
21 "pyFlakes", "Import {0!r} from line {1!r} shadowed by loop variable." |
22 'F03': QCoreApplication.translate( |
22 ), |
23 'pyFlakes', |
23 "F04": QCoreApplication.translate( |
24 'Import {0!r} from line {1!r} shadowed by loop variable.'), |
24 "pyFlakes", "'from {0} import *' used; unable to detect undefined names." |
25 'F04': QCoreApplication.translate( |
25 ), |
26 'pyFlakes', |
26 "F05": QCoreApplication.translate("pyFlakes", "Undefined name {0!r}."), |
27 "'from {0} import *' used; unable to detect undefined names."), |
27 "F06": QCoreApplication.translate("pyFlakes", "Undefined name {0!r} in __all__."), |
28 'F05': QCoreApplication.translate( |
28 "F07A": QCoreApplication.translate( |
29 'pyFlakes', |
29 "pyFlakes", |
30 'Undefined name {0!r}.'), |
|
31 'F06': QCoreApplication.translate( |
|
32 'pyFlakes', |
|
33 'Undefined name {0!r} in __all__.'), |
|
34 'F07A': QCoreApplication.translate( |
|
35 'pyFlakes', |
|
36 "Local variable {0!r} (defined in enclosing scope on line {1!r})" |
30 "Local variable {0!r} (defined in enclosing scope on line {1!r})" |
37 " referenced before assignment."), |
31 " referenced before assignment.", |
38 'F07B': QCoreApplication.translate( |
32 ), |
39 'pyFlakes', |
33 "F07B": QCoreApplication.translate( |
40 "Local variable {0!r} (defined as a builtin)" |
34 "pyFlakes", |
41 " referenced before assignment."), |
35 "Local variable {0!r} (defined as a builtin)" " referenced before assignment.", |
42 'F08': QCoreApplication.translate( |
36 ), |
43 'pyFlakes', |
37 "F08": QCoreApplication.translate( |
44 'Duplicate argument {0!r} in function definition.'), |
38 "pyFlakes", "Duplicate argument {0!r} in function definition." |
45 'F09': QCoreApplication.translate( |
39 ), |
46 'pyFlakes', |
40 "F09": QCoreApplication.translate( |
47 'Redefinition of {0!r} from line {1!r}.'), |
41 "pyFlakes", "Redefinition of {0!r} from line {1!r}." |
48 'F10': QCoreApplication.translate( |
42 ), |
49 'pyFlakes', |
43 "F10": QCoreApplication.translate( |
50 'from __future__ imports must occur at the beginning of the file'), |
44 "pyFlakes", "from __future__ imports must occur at the beginning of the file" |
51 'F11': QCoreApplication.translate( |
45 ), |
52 'pyFlakes', |
46 "F11": QCoreApplication.translate( |
53 'Local variable {0!r} is assigned to but never used.'), |
47 "pyFlakes", "Local variable {0!r} is assigned to but never used." |
54 'F12': QCoreApplication.translate( |
48 ), |
55 'pyFlakes', |
49 "F12": QCoreApplication.translate( |
56 'List comprehension redefines {0!r} from line {1!r}.'), |
50 "pyFlakes", "List comprehension redefines {0!r} from line {1!r}." |
57 'F13': QCoreApplication.translate( |
51 ), |
58 'pyFlakes', |
52 "F13": QCoreApplication.translate("pyFlakes", "Syntax error detected in doctest."), |
59 'Syntax error detected in doctest.'), |
53 "F14": QCoreApplication.translate( |
60 'F14': QCoreApplication.translate( |
54 "pyFlakes", "'return' with argument inside generator" |
61 'pyFlakes', |
55 ), |
62 "'return' with argument inside generator"), |
56 "F15": QCoreApplication.translate("pyFlakes", "'return' outside function"), |
63 'F15': QCoreApplication.translate( |
57 "F16": QCoreApplication.translate( |
64 'pyFlakes', |
58 "pyFlakes", "'from {0} import *' only allowed at module level" |
65 "'return' outside function"), |
59 ), |
66 'F16': QCoreApplication.translate( |
60 "F17": QCoreApplication.translate( |
67 'pyFlakes', |
61 "pyFlakes", "{0!r} may be undefined, or defined from star imports: {1}" |
68 "'from {0} import *' only allowed at module level"), |
62 ), |
69 'F17': QCoreApplication.translate( |
63 "F18": QCoreApplication.translate( |
70 'pyFlakes', |
64 "pyFlakes", "Dictionary key {0!r} repeated with different values" |
71 "{0!r} may be undefined, or defined from star imports: {1}"), |
65 ), |
72 'F18': QCoreApplication.translate( |
66 "F19": QCoreApplication.translate( |
73 'pyFlakes', |
67 "pyFlakes", "Dictionary key variable {0} repeated with different values" |
74 "Dictionary key {0!r} repeated with different values"), |
68 ), |
75 'F19': QCoreApplication.translate( |
69 "F20": QCoreApplication.translate("pyFlakes", "Future feature {0} is not defined"), |
76 'pyFlakes', |
70 "F21": QCoreApplication.translate("pyFlakes", "'yield' outside function"), |
77 "Dictionary key variable {0} repeated with different values"), |
71 "F22": QCoreApplication.translate("pyFlakes", "'continue' not properly in loop"), |
78 'F20': QCoreApplication.translate( |
72 "F23": QCoreApplication.translate("pyFlakes", "'break' outside loop"), |
79 'pyFlakes', |
73 "F24": QCoreApplication.translate( |
80 "Future feature {0} is not defined"), |
74 "pyFlakes", "'continue' not supported inside 'finally' clause" |
81 'F21': QCoreApplication.translate( |
75 ), |
82 'pyFlakes', |
76 "F25": QCoreApplication.translate("pyFlakes", "Default 'except:' must be last"), |
83 "'yield' outside function"), |
77 "F26": QCoreApplication.translate( |
84 'F22': QCoreApplication.translate( |
78 "pyFlakes", "Two starred expressions in assignment" |
85 'pyFlakes', |
79 ), |
86 "'continue' not properly in loop"), |
80 "F27": QCoreApplication.translate( |
87 'F23': QCoreApplication.translate( |
81 "pyFlakes", "Too many expressions in star-unpacking assignment" |
88 'pyFlakes', |
82 ), |
89 "'break' outside loop"), |
83 "F28": QCoreApplication.translate( |
90 'F24': QCoreApplication.translate( |
84 "pyFlakes", "Assertion is always true, perhaps remove parentheses?" |
91 'pyFlakes', |
85 ), |
92 "'continue' not supported inside 'finally' clause"), |
86 "F29": QCoreApplication.translate( |
93 'F25': QCoreApplication.translate( |
87 "pyFlakes", "syntax error in forward annotation {0!r}" |
94 'pyFlakes', |
88 ), |
95 "Default 'except:' must be last"), |
89 "F30": QCoreApplication.translate( |
96 'F26': QCoreApplication.translate( |
90 "pyFlakes", "'raise NotImplemented' should be 'raise NotImplementedError'" |
97 'pyFlakes', |
91 ), |
98 "Two starred expressions in assignment"), |
92 "F31": QCoreApplication.translate("pyFlakes", "syntax error in type comment {0!r}"), |
99 'F27': QCoreApplication.translate( |
93 "F32": QCoreApplication.translate( |
100 'pyFlakes', |
94 "pyFlakes", "use of >> is invalid with print function" |
101 "Too many expressions in star-unpacking assignment"), |
95 ), |
102 'F28': QCoreApplication.translate( |
96 "F33": QCoreApplication.translate( |
103 'pyFlakes', |
97 "pyFlakes", "use ==/!= to compare str, bytes, and int literals" |
104 "Assertion is always true, perhaps remove parentheses?"), |
98 ), |
105 'F29': QCoreApplication.translate( |
99 "F34": QCoreApplication.translate("pyFlakes", "f-string is missing placeholders"), |
106 'pyFlakes', |
100 "F35": QCoreApplication.translate( |
107 "syntax error in forward annotation {0!r}"), |
101 "pyFlakes", "'...'.format(...) has unused arguments at position(s): {0}" |
108 'F30': QCoreApplication.translate( |
102 ), |
109 'pyFlakes', |
103 "F36": QCoreApplication.translate( |
110 "'raise NotImplemented' should be 'raise NotImplementedError'"), |
104 "pyFlakes", "'...'.format(...) has unused named argument(s): {0}" |
111 'F31': QCoreApplication.translate( |
105 ), |
112 'pyFlakes', |
106 "F37": QCoreApplication.translate( |
113 "syntax error in type comment {0!r}"), |
107 "pyFlakes", "'...'.format(...) is missing argument(s) for placeholder(s): {0}" |
114 'F32': QCoreApplication.translate( |
108 ), |
115 'pyFlakes', |
109 "F38": QCoreApplication.translate( |
116 "use of >> is invalid with print function"), |
110 "pyFlakes", "'...'.format(...) mixes automatic and manual numbering" |
117 'F33': QCoreApplication.translate( |
111 ), |
118 'pyFlakes', |
112 "F39": QCoreApplication.translate( |
119 "use ==/!= to compare str, bytes, and int literals"), |
113 "pyFlakes", "'...'.format(...) has invalid format string: {0}" |
120 'F34': QCoreApplication.translate( |
114 ), |
121 'pyFlakes', |
115 "F40": QCoreApplication.translate( |
122 "f-string is missing placeholders"), |
116 "pyFlakes", "'...' % ... has invalid format string: {0}" |
123 'F35': QCoreApplication.translate( |
117 ), |
124 'pyFlakes', |
118 "F41": QCoreApplication.translate( |
125 "'...'.format(...) has unused arguments at position(s): {0}"), |
119 "pyFlakes", "'...' % ... has mixed positional and named placeholders" |
126 'F36': QCoreApplication.translate( |
120 ), |
127 'pyFlakes', |
121 "F42": QCoreApplication.translate( |
128 "'...'.format(...) has unused named argument(s): {0}"), |
122 "pyFlakes", "'...' % ... has unsupported format character {0!r}" |
129 'F37': QCoreApplication.translate( |
123 ), |
130 'pyFlakes', |
124 "F43": QCoreApplication.translate( |
131 "'...'.format(...) is missing argument(s) for placeholder(s): {0}"), |
125 "pyFlakes", "'...' % ... has {0:d} placeholder(s) but {1:d} substitution(s)" |
132 'F38': QCoreApplication.translate( |
126 ), |
133 'pyFlakes', |
127 "F44": QCoreApplication.translate( |
134 "'...'.format(...) mixes automatic and manual numbering"), |
128 "pyFlakes", "'...' % ... has unused named argument(s): {0}" |
135 'F39': QCoreApplication.translate( |
129 ), |
136 'pyFlakes', |
130 "F45": QCoreApplication.translate( |
137 "'...'.format(...) has invalid format string: {0}"), |
131 "pyFlakes", "'...' % ... is missing argument(s) for placeholder(s): {0}" |
138 'F40': QCoreApplication.translate( |
132 ), |
139 'pyFlakes', |
133 "F46": QCoreApplication.translate( |
140 "'...' % ... has invalid format string: {0}"), |
134 "pyFlakes", "'...' % ... expected mapping but got sequence" |
141 'F41': QCoreApplication.translate( |
135 ), |
142 'pyFlakes', |
136 "F47": QCoreApplication.translate( |
143 "'...' % ... has mixed positional and named placeholders"), |
137 "pyFlakes", "'...' % ... expected sequence but got mapping" |
144 'F42': QCoreApplication.translate( |
138 ), |
145 'pyFlakes', |
139 "F48": QCoreApplication.translate( |
146 "'...' % ... has unsupported format character {0!r}"), |
140 "pyFlakes", "'...' % ... `*` specifier requires sequence" |
147 'F43': QCoreApplication.translate( |
141 ), |
148 'pyFlakes', |
142 "F49": QCoreApplication.translate( |
149 "'...' % ... has {0:d} placeholder(s) but {1:d} substitution(s)"), |
143 "pyFlakes", |
150 'F44': QCoreApplication.translate( |
144 "'if tuple literal' is always true, perhaps remove accidental comma?", |
151 'pyFlakes', |
|
152 "'...' % ... has unused named argument(s): {0}"), |
|
153 'F45': QCoreApplication.translate( |
|
154 'pyFlakes', |
|
155 "'...' % ... is missing argument(s) for placeholder(s): {0}"), |
|
156 'F46': QCoreApplication.translate( |
|
157 'pyFlakes', |
|
158 "'...' % ... expected mapping but got sequence"), |
|
159 'F47': QCoreApplication.translate( |
|
160 'pyFlakes', |
|
161 "'...' % ... expected sequence but got mapping"), |
|
162 'F48': QCoreApplication.translate( |
|
163 'pyFlakes', |
|
164 "'...' % ... `*` specifier requires sequence"), |
|
165 'F49': QCoreApplication.translate( |
|
166 'pyFlakes', |
|
167 "'if tuple literal' is always true, perhaps remove accidental comma?" |
|
168 ), |
145 ), |
169 } |
146 } |
170 |
147 |
171 |
148 |
172 def getTranslatedFlakesMessage(message_id, message_args): |
149 def getTranslatedFlakesMessage(message_id, message_args): |
173 """ |
150 """ |
174 Module function to get a translated and formatted message for a |
151 Module function to get a translated and formatted message for a |
175 given pyflakes message ID. |
152 given pyflakes message ID. |
176 |
153 |
177 @param message_id message ID (string) |
154 @param message_id message ID (string) |
178 @param message_args arguments for a formatted message (list) |
155 @param message_args arguments for a formatted message (list) |
179 @return translated and formatted message (string) |
156 @return translated and formatted message (string) |
180 """ |
157 """ |
181 if message_id in _messages: |
158 if message_id in _messages: |