diff -r 36f66ce496bd -r 3257703e10c5 eric6/Plugins/CheckerPlugins/CodeStyleChecker/translations.py --- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/translations.py Tue Oct 13 18:23:53 2020 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/translations.py Tue Oct 13 19:02:26 2020 +0200 @@ -18,8 +18,14 @@ from .Complexity.translations import ( _complexityMessages, _complexityMessagesSampleArgs ) +from .DocStyle.translations import ( + _docStyleMessages, _docStyleMessagesSampleArgs +) +from .Miscellaneous.translations import ( + _miscellaneousMessages, _miscellaneousMessagesSampleArgs +) +from .Naming.translations import _namingStyleMessages -# TODO: separate this huge dict into separate translations per checker type _messages = { ################################################################## ## pycodestyle messages @@ -289,509 +295,6 @@ "{0}"), ################################################################## - ## DocStyleChecker messages - ################################################################## - "D101": QCoreApplication.translate( - "DocStyleChecker", "module is missing a docstring"), - "D102": QCoreApplication.translate( - "DocStyleChecker", - "public function/method is missing a docstring"), - "D103": QCoreApplication.translate( - "DocStyleChecker", - "private function/method may be missing a docstring"), - "D104": QCoreApplication.translate( - "DocStyleChecker", "public class is missing a docstring"), - "D105": QCoreApplication.translate( - "DocStyleChecker", "private class may be missing a docstring"), - "D111": QCoreApplication.translate( - "DocStyleChecker", 'docstring not surrounded by """'), - "D112": QCoreApplication.translate( - "DocStyleChecker", - 'docstring containing \\ not surrounded by r"""'), - "D121": QCoreApplication.translate( - "DocStyleChecker", "one-liner docstring on multiple lines"), - "D122": QCoreApplication.translate( - "DocStyleChecker", "docstring has wrong indentation"), - "D130": QCoreApplication.translate( - "DocStyleChecker", "docstring does not contain a summary"), - "D131": QCoreApplication.translate( - "DocStyleChecker", "docstring summary does not end with a period"), - "D132": QCoreApplication.translate( - "DocStyleChecker", - "docstring summary is not in imperative mood" - " (Does instead of Do)"), - "D133": QCoreApplication.translate( - "DocStyleChecker", - "docstring summary looks like a function's/method's signature"), - "D134": QCoreApplication.translate( - "DocStyleChecker", - "docstring does not mention the return value type"), - "D141": QCoreApplication.translate( - "DocStyleChecker", - "function/method docstring is separated by a blank line"), - "D142": QCoreApplication.translate( - "DocStyleChecker", - "class docstring is not preceded by a blank line"), - "D143": QCoreApplication.translate( - "DocStyleChecker", - "class docstring is not followed by a blank line"), - "D144": QCoreApplication.translate( - "DocStyleChecker", - "docstring summary is not followed by a blank line"), - "D145": QCoreApplication.translate( - "DocStyleChecker", - "last paragraph of docstring is not followed by a blank line"), - - "D201": QCoreApplication.translate( - "DocStyleChecker", "module docstring is still a default string"), - "D202": QCoreApplication.translate( - "DocStyleChecker", "function docstring is still a default string"), - "D203": QCoreApplication.translate( - "DocStyleChecker", - "private function/method is missing a docstring"), - "D205": QCoreApplication.translate( - "DocStyleChecker", "private class is missing a docstring"), - "D206": QCoreApplication.translate( - "DocStyleChecker", "class docstring is still a default string"), - "D221": QCoreApplication.translate( - "DocStyleChecker", - "leading quotes of docstring not on separate line"), - "D222": QCoreApplication.translate( - "DocStyleChecker", - "trailing quotes of docstring not on separate line"), - "D231": QCoreApplication.translate( - "DocStyleChecker", "docstring summary does not end with a period"), - "D232": QCoreApplication.translate( - "DocStyleChecker", "docstring summary does not start with '{0}'"), - "D234": QCoreApplication.translate( - "DocStyleChecker", - "docstring does not contain a @return line but function/method" - " returns something"), - "D235": QCoreApplication.translate( - "DocStyleChecker", - "docstring contains a @return line but function/method doesn't" - " return anything"), - "D236": QCoreApplication.translate( - "DocStyleChecker", - "docstring does not contain enough @param/@keyparam lines"), - "D237": QCoreApplication.translate( - "DocStyleChecker", - "docstring contains too many @param/@keyparam lines"), - "D238": QCoreApplication.translate( - "DocStyleChecker", - "keyword only arguments must be documented with @keyparam lines"), - "D239": QCoreApplication.translate( - "DocStyleChecker", "order of @param/@keyparam lines does" - " not match the function/method signature"), - "D242": QCoreApplication.translate( - "DocStyleChecker", "class docstring is preceded by a blank line"), - "D243": QCoreApplication.translate( - "DocStyleChecker", "class docstring is followed by a blank line"), - "D244": QCoreApplication.translate( - "DocStyleChecker", - "function/method docstring is preceded by a blank line"), - "D245": QCoreApplication.translate( - "DocStyleChecker", - "function/method docstring is followed by a blank line"), - "D246": QCoreApplication.translate( - "DocStyleChecker", - "docstring summary is not followed by a blank line"), - "D247": QCoreApplication.translate( - "DocStyleChecker", - "last paragraph of docstring is followed by a blank line"), - "D250": QCoreApplication.translate( - "DocStyleChecker", - "docstring does not contain a @exception line but function/method" - " raises an exception"), - "D251": QCoreApplication.translate( - "DocStyleChecker", - "docstring contains a @exception line but function/method doesn't" - " raise an exception"), - "D252": QCoreApplication.translate( - "DocStyleChecker", - "raised exception '{0}' is not documented in docstring"), - "D253": QCoreApplication.translate( - "DocStyleChecker", - "documented exception '{0}' is not raised"), - "D260": QCoreApplication.translate( - "DocStyleChecker", - "docstring does not contain a @signal line but class defines signals"), - "D261": QCoreApplication.translate( - "DocStyleChecker", - "docstring contains a @signal line but class doesn't define signals"), - "D262": QCoreApplication.translate( - "DocStyleChecker", - "defined signal '{0}' is not documented in docstring"), - "D263": QCoreApplication.translate( - "DocStyleChecker", - "documented signal '{0}' is not defined"), - - "D901": QCoreApplication.translate( - "DocStyleChecker", "{0}: {1}"), - - ################################################################## - ## NamingStyleChecker messages - ################################################################## - "N801": QCoreApplication.translate( - "NamingStyleChecker", - "class names should use CapWords convention"), - "N802": QCoreApplication.translate( - "NamingStyleChecker", - "function name should be lowercase"), - "N803": QCoreApplication.translate( - "NamingStyleChecker", - "argument name should be lowercase"), - "N804": QCoreApplication.translate( - "NamingStyleChecker", - "first argument of a class method should be named 'cls'"), - "N805": QCoreApplication.translate( - "NamingStyleChecker", - "first argument of a method should be named 'self'"), - "N806": QCoreApplication.translate( - "NamingStyleChecker", - "first argument of a static method should not be named" - " 'self' or 'cls"), - "N807": QCoreApplication.translate( - "NamingStyleChecker", - "module names should be lowercase"), - "N808": QCoreApplication.translate( - "NamingStyleChecker", - "package names should be lowercase"), - "N811": QCoreApplication.translate( - "NamingStyleChecker", - "constant imported as non constant"), - "N812": QCoreApplication.translate( - "NamingStyleChecker", - "lowercase imported as non lowercase"), - "N813": QCoreApplication.translate( - "NamingStyleChecker", - "camelcase imported as lowercase"), - "N814": QCoreApplication.translate( - "NamingStyleChecker", - "camelcase imported as constant"), - "N821": QCoreApplication.translate( - "NamingStyleChecker", - "variable in function should be lowercase"), - "N831": QCoreApplication.translate( - "NamingStyleChecker", - "names 'l', 'O' and 'I' should be avoided"), - - ################################################################## - ## Messages of the Miscellaneous Checker - ################################################################## - "M101": QCoreApplication.translate( - "MiscellaneousChecker", - "coding magic comment not found"), - "M102": QCoreApplication.translate( - "MiscellaneousChecker", - "unknown encoding ({0}) found in coding magic comment"), - "M111": QCoreApplication.translate( - "MiscellaneousChecker", - "copyright notice not present"), - "M112": QCoreApplication.translate( - "MiscellaneousChecker", - "copyright notice contains invalid author"), - "M131": QCoreApplication.translate( - "MiscellaneousChecker", - '"{0}" is a Python builtin and is being shadowed; ' - 'consider renaming the variable'), - "M132": QCoreApplication.translate( - "MiscellaneousChecker", - '"{0}" is used as an argument and thus shadows a ' - 'Python builtin; consider renaming the argument'), - "M181": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary generator - rewrite as a list comprehension'), - "M182": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary generator - rewrite as a set comprehension'), - "M183": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary generator - rewrite as a dict comprehension'), - "M184": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary list comprehension - rewrite as a set comprehension'), - "M185": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary list comprehension - rewrite as a dict comprehension'), - "M186": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary {0} call - rewrite as a literal'), - "M187": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary list comprehension - "{0}" can take a generator'), - "M191": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary {0} literal - rewrite as a {1} literal'), - "M192": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary {0} passed to tuple() - rewrite as a {1} literal'), - "M193": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary {0} passed to list() - rewrite as a {1} literal'), - "M195": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary list call - remove the outer call to list()'), - "M196": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary list comprehension - "in" can take a generator'), - "M197": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary {0} passed to tuple() - remove the outer call to {1}()'), - "M198": QCoreApplication.translate( - "MiscellaneousChecker", - 'unnecessary {0} passed to list() - remove the outer call to {1}()'), - - "M201": QCoreApplication.translate( - "MiscellaneousChecker", - "sort keys - '{0}' should be before '{1}'"), - - "M301": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime()' without 'tzinfo' argument should be" - " avoided"), - "M302": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime.today()' should be avoided.\n" - "Use 'datetime.datetime.now(tz=)' instead."), - "M303": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime.utcnow()' should be avoided.\n" - "Use 'datetime.datetime.now(tz=)' instead."), - "M304": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime.utcfromtimestamp()' should be avoided.\n" - "Use 'datetime.datetime.fromtimestamp(, tz=)' instead."), - "M305": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime.now()' without 'tz' argument should be" - " avoided"), - "M306": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime.fromtimestamp()' without 'tz' argument" - " should be avoided"), - "M307": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime.strptime()' should be followed by" - " '.replace(tzinfo=)'"), - "M308": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.datetime.fromordinal()' should be avoided"), - "M311": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.date()' should be avoided.\n" - "Use 'datetime.datetime(, tzinfo=).date()' instead."), - "M312": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.date.today()' should be avoided.\n" - "Use 'datetime.datetime.now(tz=).date()' instead."), - "M313": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.date.fromtimestamp()' should be avoided.\n" - "Use 'datetime.datetime.fromtimestamp(tz=).date()' instead."), - "M314": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.date.fromordinal()' should be avoided"), - "M315": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.date.fromisoformat()' should be avoided"), - "M321": QCoreApplication.translate( - "MiscellaneousChecker", - "use of 'datetime.time()' without 'tzinfo' argument should be" - " avoided"), - - "M401": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version[:3]' referenced (Python 3.10), use 'sys.version_info'"), - "M402": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version[2]' referenced (Python 3.10), use 'sys.version_info'"), - "M403": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version' compared to string (Python 3.10), use" - " 'sys.version_info'"), - "M411": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version_info[0] == 3' referenced (Python 4), use '>='"), - "M412": QCoreApplication.translate( - "MiscellaneousChecker", - "'six.PY3' referenced (Python 4), use 'not six.PY2'"), - "M413": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version_info[1]' compared to integer (Python 4)," - " compare 'sys.version_info' to tuple"), - "M414": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version_info.minor' compared to integer (Python 4)," - " compare 'sys.version_info' to tuple"), - "M421": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version[0]' referenced (Python 10), use 'sys.version_info'"), - "M422": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version' compared to string (Python 10)," - " use 'sys.version_info'"), - "M423": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.version[:1]' referenced (Python 10), use 'sys.version_info'"), - - "M501": QCoreApplication.translate( - "MiscellaneousChecker", - "Python does not support the unary prefix increment"), - "M502": QCoreApplication.translate( - "MiscellaneousChecker", - "using .strip() with multi-character strings is misleading"), - "M503": QCoreApplication.translate( - "MiscellaneousChecker", - "do not call assert False since python -O removes these calls"), - "M504": QCoreApplication.translate( - "MiscellaneousChecker", - "'sys.maxint' is not defined in Python 3 - use 'sys.maxsize'"), - "M505": QCoreApplication.translate( - "MiscellaneousChecker", - "'BaseException.message' has been deprecated as of Python 2.6 and is" - " removed in Python 3 - use 'str(e)'"), - "M506": QCoreApplication.translate( - "MiscellaneousChecker", - "assigning to 'os.environ' does not clear the environment -" - " use 'os.environ.clear()'"), - "M507": QCoreApplication.translate( - "MiscellaneousChecker", - "loop control variable {0} not used within the loop body -" - " start the name with an underscore"), - "M508": QCoreApplication.translate( - "MiscellaneousChecker", - "unncessary f-string"), - "M509": QCoreApplication.translate( - "MiscellaneousChecker", - "cannot use 'self.__class__' as first argument of 'super()' call"), - "M511": QCoreApplication.translate( - "MiscellaneousChecker", - """using 'hasattr(x, "__call__")' to test if 'x' is callable is""" - """ unreliable"""), - "M512": QCoreApplication.translate( - "MiscellaneousChecker", - "do not call getattr with a constant attribute value"), - "M513": QCoreApplication.translate( - "MiscellaneousChecker", - "do not call setattr with a constant attribute value"), - "M521": QCoreApplication.translate( - "MiscellaneousChecker", - "Python 3 does not include '.iter*' methods on dictionaries"), - "M522": QCoreApplication.translate( - "MiscellaneousChecker", - "Python 3 does not include '.view*' methods on dictionaries"), - "M523": QCoreApplication.translate( - "MiscellaneousChecker", - "'.next()' does not exist in Python 3"), - "M524": QCoreApplication.translate( - "MiscellaneousChecker", - "'__metaclass__' does nothing on Python 3 -" - " use 'class MyClass(BaseClass, metaclass=...)'"), - - "M601": QCoreApplication.translate( - "MiscellaneousChecker", - "found {0} formatter"), - "M611": QCoreApplication.translate( - "MiscellaneousChecker", - "format string does contain unindexed parameters"), - "M612": QCoreApplication.translate( - "MiscellaneousChecker", - "docstring does contain unindexed parameters"), - "M613": QCoreApplication.translate( - "MiscellaneousChecker", - "other string does contain unindexed parameters"), - "M621": QCoreApplication.translate( - "MiscellaneousChecker", - "format call uses too large index ({0})"), - "M622": QCoreApplication.translate( - "MiscellaneousChecker", - "format call uses missing keyword ({0})"), - "M623": QCoreApplication.translate( - "MiscellaneousChecker", - "format call uses keyword arguments but no named entries"), - "M624": QCoreApplication.translate( - "MiscellaneousChecker", - "format call uses variable arguments but no numbered entries"), - "M625": QCoreApplication.translate( - "MiscellaneousChecker", - "format call uses implicit and explicit indexes together"), - "M631": QCoreApplication.translate( - "MiscellaneousChecker", - "format call provides unused index ({0})"), - "M632": QCoreApplication.translate( - "MiscellaneousChecker", - "format call provides unused keyword ({0})"), - "M651": QCoreApplication.translate( - "MiscellaneousChecker", - "logging statement uses string.format()"), - "M652": QCoreApplication.translate( - "MiscellaneousChecker", - "logging statement uses '%'"), # __IGNORE_WARNING_M601__ - "M653": QCoreApplication.translate( - "MiscellaneousChecker", - "logging statement uses '+'"), - "M654": QCoreApplication.translate( - "MiscellaneousChecker", - "logging statement uses f-string"), - "M655": QCoreApplication.translate( - "MiscellaneousChecker", - "logging statement uses 'warn' instead of 'warning'"), - - "M701": QCoreApplication.translate( - "MiscellaneousChecker", - "expected these __future__ imports: {0}; but only got: {1}"), - "M702": QCoreApplication.translate( - "MiscellaneousChecker", - "expected these __future__ imports: {0}; but got none"), - "M711": QCoreApplication.translate( - "MiscellaneousChecker", - "gettext import with alias _ found: {0}"), - - "M801": QCoreApplication.translate( - "MiscellaneousChecker", - "print statement found"), - "M811": QCoreApplication.translate( - "MiscellaneousChecker", - "one element tuple found"), - "M821": QCoreApplication.translate( - "MiscellaneousChecker", - "mutable default argument of type {0}"), - "M822": QCoreApplication.translate( - "MiscellaneousChecker", - "mutable default argument of type {0}"), - "M823": QCoreApplication.translate( - "MiscellaneousChecker", - "mutable default argument of function call '{0}'"), - "M831": QCoreApplication.translate( - "MiscellaneousChecker", - "None should not be added at any return if function has no return" - " value except None"), - "M832": QCoreApplication.translate( - "MiscellaneousChecker", - "an explicit value at every return should be added if function has" - " a return value except None"), - "M833": QCoreApplication.translate( - "MiscellaneousChecker", - "an explicit return at the end of the function should be added if" - " it has a return value except None"), - "M834": QCoreApplication.translate( - "MiscellaneousChecker", - "a value should not be assigned to a variable if it will be used as a" - " return value only"), - "M841": QCoreApplication.translate( - "MiscellaneousChecker", - "prefer implied line continuation inside parentheses, " - "brackets and braces as opposed to a backslash"), - "M891": QCoreApplication.translate( - "MiscellaneousChecker", - "commented code lines should be removed"), - - "M901": QCoreApplication.translate( - "MiscellaneousChecker", - "{0}: {1}"), - - ################################################################## ## CodeStyleFixer messages ################################################################## @@ -970,38 +473,6 @@ "E901": ["SyntaxError", "Invalid Syntax"], "E902": ["IOError"], - "D232": ["public"], - "D252": ["RuntimeError"], - "D253": ["RuntimeError"], - "D262": ["buttonClicked"], - "D263": ["buttonClicked"], - "D901": ["SyntaxError", "Invalid Syntax"], - - "M102": ["enc42"], - "M131": ["list"], - "M132": ["list"], - "M188": ["sorted"], - "M186": ["list"], - "M191": ["list", "set"], - "M192": ["list", "tuple"], - "M193": ["tuple", "list"], - "M197": ["tuple", "tuple"], - "M198": ["list", "list"], - "M201": ["bar", "foo"], - "M507": ["x"], - "M601": ["%s"], - "M621": [5], - "M622": ["foo"], - "M631": [5], - "M632": ["foo"], - "M701": ["print_function, unicode_literals", "print_function"], - "M702": ["print_function, unicode_literals"], - "M711": ["lgettext"], - "M821": ["Dict"], - "M822": ["Call"], - "M823": ["dict"], - "M901": ["SyntaxError", "Invalid Syntax"], - "FIXWRITE_ERROR": ["IOError"], } @@ -1010,6 +481,9 @@ _securityMessages, _annotationsMessages, _complexityMessages, + _docStyleMessages, + _miscellaneousMessages, + _namingStyleMessages, ) messageSampleArgsCatalog = ( @@ -1017,6 +491,8 @@ _securityMessagesSampleArgs, _annotationsMessagesSampleArgs, _complexityMessagesSampleArgs, + _docStyleMessagesSampleArgs, + _miscellaneousMessagesSampleArgs, )