eric7/Plugins/CheckerPlugins/SyntaxChecker/pyflakes/translations.py

branch
eric7
changeset 8312
800c432b34c8
parent 7923
91e843545d9a
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing message translations for pyflakes warning messages.
8 """
9
10
11 from PyQt5.QtCore import QCoreApplication
12
13 __all__ = ["getTranslatedFlakesMessage"]
14
15 _messages = {
16 'F01': QCoreApplication.translate(
17 'pyFlakes',
18 '{0!r} imported but unused.'),
19 'F02': QCoreApplication.translate(
20 'pyFlakes',
21 'Redefinition of unused {0!r} from line {1!r}.'),
22 'F03': QCoreApplication.translate(
23 'pyFlakes',
24 'Import {0!r} from line {1!r} shadowed by loop variable.'),
25 'F04': QCoreApplication.translate(
26 'pyFlakes',
27 "'from {0} import *' used; unable to detect undefined names."),
28 'F05': QCoreApplication.translate(
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})"
37 " referenced before assignment."),
38 'F07B': QCoreApplication.translate(
39 'pyFlakes',
40 "Local variable {0!r} (defined as a builtin)"
41 " referenced before assignment."),
42 'F08': QCoreApplication.translate(
43 'pyFlakes',
44 'Duplicate argument {0!r} in function definition.'),
45 'F09': QCoreApplication.translate(
46 'pyFlakes',
47 'Redefinition of {0!r} from line {1!r}.'),
48 'F10': QCoreApplication.translate(
49 'pyFlakes',
50 'from __future__ imports must occur at the beginning of the file'),
51 'F11': QCoreApplication.translate(
52 'pyFlakes',
53 'Local variable {0!r} is assigned to but never used.'),
54 'F12': QCoreApplication.translate(
55 'pyFlakes',
56 'List comprehension redefines {0!r} from line {1!r}.'),
57 'F13': QCoreApplication.translate(
58 'pyFlakes',
59 'Syntax error detected in doctest.'),
60 'F14': QCoreApplication.translate(
61 'pyFlakes',
62 "'return' with argument inside generator"),
63 'F15': QCoreApplication.translate(
64 'pyFlakes',
65 "'return' outside function"),
66 'F16': QCoreApplication.translate(
67 'pyFlakes',
68 "'from {0} import *' only allowed at module level"),
69 'F17': QCoreApplication.translate(
70 'pyFlakes',
71 "{0!r} may be undefined, or defined from star imports: {1}"),
72 'F18': QCoreApplication.translate(
73 'pyFlakes',
74 "Dictionary key {0!r} repeated with different values"),
75 'F19': QCoreApplication.translate(
76 'pyFlakes',
77 "Dictionary key variable {0} repeated with different values"),
78 'F20': QCoreApplication.translate(
79 'pyFlakes',
80 "Future feature {0} is not defined"),
81 'F21': QCoreApplication.translate(
82 'pyFlakes',
83 "'yield' outside function"),
84 'F22': QCoreApplication.translate(
85 'pyFlakes',
86 "'continue' not properly in loop"),
87 'F23': QCoreApplication.translate(
88 'pyFlakes',
89 "'break' outside loop"),
90 'F24': QCoreApplication.translate(
91 'pyFlakes',
92 "'continue' not supported inside 'finally' clause"),
93 'F25': QCoreApplication.translate(
94 'pyFlakes',
95 "Default 'except:' must be last"),
96 'F26': QCoreApplication.translate(
97 'pyFlakes',
98 "Two starred expressions in assignment"),
99 'F27': QCoreApplication.translate(
100 'pyFlakes',
101 "Too many expressions in star-unpacking assignment"),
102 'F28': QCoreApplication.translate(
103 'pyFlakes',
104 "Assertion is always true, perhaps remove parentheses?"),
105 'F29': QCoreApplication.translate(
106 'pyFlakes',
107 "syntax error in forward annotation {0!r}"),
108 'F30': QCoreApplication.translate(
109 'pyFlakes',
110 "'raise NotImplemented' should be 'raise NotImplementedError'"),
111 'F31': QCoreApplication.translate(
112 'pyFlakes',
113 "syntax error in type comment {0!r}"),
114 'F32': QCoreApplication.translate(
115 'pyFlakes',
116 "use of >> is invalid with print function"),
117 'F33': QCoreApplication.translate(
118 'pyFlakes',
119 "use ==/!= to compare str, bytes, and int literals"),
120 'F34': QCoreApplication.translate(
121 'pyFlakes',
122 "f-string is missing placeholders"),
123 'F35': QCoreApplication.translate(
124 'pyFlakes',
125 "'...'.format(...) has unused arguments at position(s): {0}"),
126 'F36': QCoreApplication.translate(
127 'pyFlakes',
128 "'...'.format(...) has unused named argument(s): {0}"),
129 'F37': QCoreApplication.translate(
130 'pyFlakes',
131 "'...'.format(...) is missing argument(s) for placeholder(s): {0}"),
132 'F38': QCoreApplication.translate(
133 'pyFlakes',
134 "'...'.format(...) mixes automatic and manual numbering"),
135 'F39': QCoreApplication.translate(
136 'pyFlakes',
137 "'...'.format(...) has invalid format string: {0}"),
138 'F40': QCoreApplication.translate(
139 'pyFlakes',
140 "'...' % ... has invalid format string: {0}"),
141 'F41': QCoreApplication.translate(
142 'pyFlakes',
143 "'...' % ... has mixed positional and named placeholders"),
144 'F42': QCoreApplication.translate(
145 'pyFlakes',
146 "'...' % ... has unsupported format character {0!r}"),
147 'F43': QCoreApplication.translate(
148 'pyFlakes',
149 "'...' % ... has {0:d} placeholder(s) but {1:d} substitution(s)"),
150 'F44': QCoreApplication.translate(
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 ),
169 }
170
171
172 def getTranslatedFlakesMessage(message_id, message_args):
173 """
174 Module function to get a translated and formatted message for a
175 given pyflakes message ID.
176
177 @param message_id message ID (string)
178 @param message_args arguments for a formatted message (list)
179 @return translated and formatted message (string)
180 """
181 if message_id in _messages:
182 msg = _messages[message_id].replace("{0!r}", "'{0}'")
183 msg = msg.replace("{1!r}", "'{1}'")
184 return msg.format(*message_args)
185 else:
186 return QCoreApplication.translate(
187 "pyFlakes", "no message defined for code '{0}'"
188 ).format(message_id)

eric ide

mercurial