--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/translations.py Wed Sep 14 11:07:55 2022 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/translations.py Thu Sep 15 10:09:53 2022 +0200 @@ -208,66 +208,119 @@ "'sys.version[:1]' referenced (Python 10), use 'sys.version_info'", ), "M501": QCoreApplication.translate( - "MiscellaneousChecker", "Python does not support the unary prefix increment" + "MiscellaneousChecker", + "Do not use 'except (){0}:', it also catches unexpected events. Prefer" + " 'except Exception:'.", ), "M502": QCoreApplication.translate( - "MiscellaneousChecker", - "using .strip() with multi-character strings is misleading", + "MiscellaneousChecker", "Python does not support the unary prefix increment" ), "M503": QCoreApplication.translate( "MiscellaneousChecker", - "do not call assert False since python -O removes these calls", + "assigning to 'os.environ' does not clear the environment -" + " use 'os.environ.clear()'", ), "M504": QCoreApplication.translate( "MiscellaneousChecker", - "'sys.maxint' is not defined in Python 3 - use 'sys.maxsize'", + """using 'hasattr(x, "__call__")' to test if 'x' is callable is""" + """ unreliable. Use 'callable(x)' for consistent results.""", ), "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()'", + "using .strip() with multi-character strings is misleading. Use " + ".replace() or regular expressions to remove string fragments.", ), "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", + "MiscellaneousChecker", "do not call getattr with a constant attribute value" + ), + "M510": QCoreApplication.translate( + "MiscellaneousChecker", "do not call setattr with a constant attribute value" ), "M511": QCoreApplication.translate( "MiscellaneousChecker", - """using 'hasattr(x, "__call__")' to test if 'x' is callable is""" - """ unreliable""", + "do not call assert False since python -O removes these calls", ), "M512": QCoreApplication.translate( - "MiscellaneousChecker", "do not call getattr with a constant attribute value" + "MiscellaneousChecker", + "return/continue/break inside finally blocks cause exceptions to be silenced." + " Exceptions should be silenced in except blocks. Control statements can be" + " moved outside the finally block.", ), "M513": QCoreApplication.translate( - "MiscellaneousChecker", "do not call setattr with a constant attribute value" + "MiscellaneousChecker", + "A length-one tuple literal is redundant. Write 'except {0}:' instead of" + " 'except ({0},):'.", + ), + "M514": QCoreApplication.translate( + "MiscellaneousChecker", + "Redundant exception types in 'except ({0}){1}:'. Write 'except {2}{1}:'," + " which catches exactly the same exceptions.", + ), + "M515": QCoreApplication.translate( + "MiscellaneousChecker", + "Pointless comparison. This comparison does nothing but waste CPU instructions." + " Either prepend 'assert' or remove it.", + ), + "M516": QCoreApplication.translate( + "MiscellaneousChecker", + "Cannot raise a literal. Did you intend to return it or raise an Exception?", + ), + "M517": QCoreApplication.translate( + "MiscellaneousChecker", + "'assertRaises(Exception):' should be considered evil. It can lead to your test" + " passing even if the code being tested is never executed due to a typo. Either" + " assert for a more specific exception (builtin or custom), use" + " 'assertRaisesRegex', or use the context manager form of 'assertRaises'.", + ), + "M518": QCoreApplication.translate( + "MiscellaneousChecker", + "Found useless expression. Either assign it to a variable or remove it.", + ), + "M519": QCoreApplication.translate( + "MiscellaneousChecker", + "Use of 'functools.lru_cache' or 'functools.cache' on methods can lead to" + " memory leaks. The cache may retain instance references, preventing garbage" + " collection.", + ), + "M520": QCoreApplication.translate( + "MiscellaneousChecker", + "Found for loop that reassigns the iterable it is iterating with each" + " iterable value.", ), "M521": QCoreApplication.translate( "MiscellaneousChecker", - "Python 3 does not include '.iter*' methods on dictionaries", + "f-string used as docstring. This will be interpreted by python as a joined" + " string rather than a docstring.", ), "M522": QCoreApplication.translate( "MiscellaneousChecker", - "Python 3 does not include '.view*' methods on dictionaries", + "No arguments passed to 'contextlib.suppress'. No exceptions will be" + " suppressed and therefore this context manager is redundant.", ), "M523": QCoreApplication.translate( - "MiscellaneousChecker", "'.next()' does not exist in Python 3" + "MiscellaneousChecker", + "Function definition does not bind loop variable '{0}'.", ), "M524": QCoreApplication.translate( "MiscellaneousChecker", - "'__metaclass__' does nothing on Python 3 -" - " use 'class MyClass(BaseClass, metaclass=...)'", + "{0} is an abstract base class, but it has no abstract methods. Remember to" + " use '@abstractmethod', '@abstractclassmethod' and/or '@abstractproperty'" + " decorators.", + ), + "M525": QCoreApplication.translate( + "MiscellaneousChecker", + "Exception '{0}' has been caught multiple times. Only the first except will be" + " considered and all other except catches can be safely removed.", + ), + "M581": QCoreApplication.translate("MiscellaneousChecker", "unncessary f-string"), + "M582": QCoreApplication.translate( + "MiscellaneousChecker", + "cannot use 'self.__class__' as first argument of 'super()' call", ), "M601": QCoreApplication.translate("MiscellaneousChecker", "found {0} formatter"), "M611": QCoreApplication.translate( @@ -388,7 +441,13 @@ "M197": ["tuple", "tuple"], "M198": ["list", "list"], "M201": ["bar", "foo"], + "M501": [" as err"], "M507": ["x"], + "M513": ["Exception"], + "M514": ["OSError, IOError", " as err", "OSError"], + "M523": ["x"], + "M524": ["foobar"], + "M525": ["OSError"], "M601": ["%s"], "M621": [5], "M622": ["foo"],