Fri, 01 Sep 2023 15:31:04 +0200
Updated some codestyle checkers for imports and too complex annotations.
--- a/docs/ThirdParty.md Fri Sep 01 10:27:56 2023 +0200 +++ b/docs/ThirdParty.md Fri Sep 01 15:31:04 2023 +0200 @@ -20,7 +20,7 @@ |:-----------------------------:|:---------:|:-----------------------------------| | flake8-alphabetize | 0.0.21 | MIT License (MIT No Attribution) | | flake8-annotations | 3.0.1 | MIT License (MIT) | -| flake8-annotations-complexity | 0.0.7 | MIT License (MIT) | +| flake8-annotations-complexity | 0.0.8 | MIT License (MIT) | | flake8-annotations-coverage | 0.0.6 | MIT License (MIT) | | flake8-async | 22.11.14 | MIT License (MIT) | | flake8-bugbear | 23.5.9 | MIT License (MIT) | @@ -29,7 +29,7 @@ | flake8-pep585 | 0.1.7 | Mozilla Public License Version 2.0 | | flake8-pep604 | 1.1.0 | MIT License (MIT) | | flake8-simplify | 0.20.0 | MIT License (MIT) | -| flake8-tidy-imports | 4.8.0 | MIT License (MIT) | +| flake8-tidy-imports | 4.10.0 | MIT License (MIT) | | flake8-unused-arguments | 0.0.13 | MIT License (MIT) | | flake8-unused-globals | 0.1.9 | MIT License (MIT) | | flake8-use-pathlib | 0.3.0 | MIT License (MIT) |
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Fri Sep 01 10:27:56 2023 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsChecker.py Fri Sep 01 15:31:04 2023 +0200 @@ -504,7 +504,7 @@ ####################################################################### ## Annotations Complexity ## - ## adapted from: flake8-annotations-complexity v0.0.7 + ## adapted from: flake8-annotations-complexity v0.0.8 ####################################################################### def __checkAnnotationComplexity(self):
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/ImportsChecker.py Fri Sep 01 10:27:56 2023 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/ImportsChecker.py Fri Sep 01 15:31:04 2023 +0200 @@ -162,7 +162,7 @@ ####################################################################### ## Tidy imports ## - ## adapted from: flake8-tidy-imports v4.8.0 + ## adapted from: flake8-tidy-imports v4.10.0 ####################################################################### def __tidyImports(self): @@ -245,16 +245,16 @@ if importedName == alias.asname: if fromName: - rewritten = "from {0} import {1}".format(fromName, importedName) + rewritten = f"from {fromName} import {importedName}" else: - rewritten = "import {0}".format(importedName) + rewritten = f"import {importedName}" self.__error(node.lineno - 1, node.col_offset, "I901", rewritten) elif isinstance(node, ast.ImportFrom): for alias in node.names: if alias.name == alias.asname: - rewritten = "from {0} import {1}".format(node.module, alias.name) + rewritten = f"from {node.module} import {alias.name}" self.__error(node.lineno - 1, node.col_offset, "I901", rewritten) @@ -293,7 +293,12 @@ @param node reference to the node to be checked @type ast.AST """ - if not bool(self.__bannedModules): + if ( + not bool(self.__bannedModules) + and not bool(self.__bannedUnstructuredPatterns) + and not bool(self.__bannedStructuredPatterns) + ): + # nothing to check return if isinstance(node, ast.Import): @@ -329,6 +334,7 @@ @type ast.AST """ if not self.__banRelativeImports: + # nothing to check return elif self.__banRelativeImports == "parents": @@ -339,8 +345,7 @@ msgCode = "I904" if ( - self.__banRelativeImports - and isinstance(node, ast.ImportFrom) + isinstance(node, ast.ImportFrom) and node.level > minNodeLevel ): self.__error(node.lineno - 1, node.col_offset, msgCode)