From 06a7bc5daf227e4b14cb067f4ffa4ec30eb59b44 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 19 Sep 2024 11:53:10 +0200 Subject: [PATCH 1/6] Remove check Conans import Signed-off-by: Uilian Ries --- linter/check_import_conanfile.py | 28 ---------------------------- linter/conanv2_transition.py | 2 -- 2 files changed, 30 deletions(-) delete mode 100644 linter/check_import_conanfile.py diff --git a/linter/check_import_conanfile.py b/linter/check_import_conanfile.py deleted file mode 100644 index bd5a90391b096..0000000000000 --- a/linter/check_import_conanfile.py +++ /dev/null @@ -1,28 +0,0 @@ - -from pylint.checkers import BaseChecker -from pylint.interfaces import IAstroidChecker -from astroid import nodes, Const, AssignName - - -class ImportConanFile(BaseChecker): - """ - Import ConanFile from new 'conan' module - """ - - __implements__ = IAstroidChecker - - name = "conan-import-conanfile" - msgs = { - "E9006": ( - "Import ConanFile from new module: `from conan import ConanFile`. Old import is deprecated in Conan v2.", - "conan-import-conanfile", - "Import ConanFile from new module: `from conan import ConanFile`. Old import is deprecated in Conan v2.", - ), - } - - def visit_importfrom(self, node: nodes.ImportFrom) -> None: - basename = node.modname - if basename == 'conans': - names = [name for name, _ in node.names] - if 'ConanFile' in names: - self.add_message("conan-import-conanfile", node=node) diff --git a/linter/conanv2_transition.py b/linter/conanv2_transition.py index e330ff1d44590..21941de8e9f00 100644 --- a/linter/conanv2_transition.py +++ b/linter/conanv2_transition.py @@ -6,7 +6,6 @@ from pylint.lint import PyLinter from linter.check_package_name import PackageName -from linter.check_import_conanfile import ImportConanFile from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors from linter.check_import_tools import ImportTools from linter.check_layout_src_folder import LayoutSrcFolder @@ -15,7 +14,6 @@ def register(linter: PyLinter) -> None: linter.register_checker(PackageName(linter)) - linter.register_checker(ImportConanFile(linter)) linter.register_checker(ImportErrors(linter)) linter.register_checker(ImportErrorsConanException(linter)) linter.register_checker(ImportErrorsConanInvalidConfiguration(linter)) From bf028ee7b3600038c712108794497442d8dd575d Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 19 Sep 2024 11:57:05 +0200 Subject: [PATCH 2/6] Remove check conans import Signed-off-by: Uilian Ries --- linter/check_import_errors.py | 77 ----------------------------------- linter/conanv2_transition.py | 4 -- 2 files changed, 81 deletions(-) delete mode 100644 linter/check_import_errors.py diff --git a/linter/check_import_errors.py b/linter/check_import_errors.py deleted file mode 100644 index b6a0ac1aa9973..0000000000000 --- a/linter/check_import_errors.py +++ /dev/null @@ -1,77 +0,0 @@ - -from pylint.checkers import BaseChecker -from pylint.interfaces import IAstroidChecker -from astroid import nodes, Const, AssignName - - -class ImportErrors(BaseChecker): - """ - Import errors from new 'conan' module - """ - - __implements__ = IAstroidChecker - - name = "conan-import-errors" - msgs = { - "E9008": ( - "Import errors from new module: `from conan import errors`. Old import is deprecated in Conan v2.", - "conan-import-errors", - "Import errors from new module: `from conan import errors`. Old import is deprecated in Conan v2.", - ), - } - - def visit_importfrom(self, node: nodes.ImportFrom) -> None: - basename = node.modname - if basename == 'conans': - names = [name for name, _ in node.names] - if 'errors' in names: - self.add_message("conan-import-errors", node=node) - - -class ImportErrorsConanException(BaseChecker): - """ - Import errors from new 'conan' module - """ - - __implements__ = IAstroidChecker - - name = "conan-import-error-conanexception" - msgs = { - "E9009": ( - "Import ConanException from new module: `from conan.errors import ConanException`. Old import is deprecated in Conan v2.", - "conan-import-error-conanexception", - "Import ConanException from new module: `from conan.errors import ConanException`. Old import is deprecated in Conan v2.", - ), - } - - def visit_importfrom(self, node: nodes.ImportFrom) -> None: - basename = node.modname - if basename == 'conans.errors': - names = [name for name, _ in node.names] - if 'ConanException' in names: - self.add_message("conan-import-error-conanexception", node=node) - - -class ImportErrorsConanInvalidConfiguration(BaseChecker): - """ - Import errors from new 'conan' module - """ - - __implements__ = IAstroidChecker - - name = "conan-import-error-conaninvalidconfiguration" - msgs = { - "E9010": ( - "Import ConanInvalidConfiguration from new module: `from conan.errors import ConanInvalidConfiguration`. Old import is deprecated in Conan v2.", - "conan-import-error-conaninvalidconfiguration", - "Import ConanInvalidConfiguration from new module: `from conan.errors import ConanInvalidConfiguration`. Old import is deprecated in Conan v2.", - ), - } - - def visit_importfrom(self, node: nodes.ImportFrom) -> None: - basename = node.modname - if basename == 'conans.errors': - names = [name for name, _ in node.names] - if 'ConanInvalidConfiguration' in names: - self.add_message("conan-import-error-conaninvalidconfiguration", node=node) - diff --git a/linter/conanv2_transition.py b/linter/conanv2_transition.py index 21941de8e9f00..32fbb30499363 100644 --- a/linter/conanv2_transition.py +++ b/linter/conanv2_transition.py @@ -6,7 +6,6 @@ from pylint.lint import PyLinter from linter.check_package_name import PackageName -from linter.check_import_errors import ImportErrorsConanException, ImportErrorsConanInvalidConfiguration, ImportErrors from linter.check_import_tools import ImportTools from linter.check_layout_src_folder import LayoutSrcFolder from linter.check_version_attribute import VersionAttribute @@ -14,9 +13,6 @@ def register(linter: PyLinter) -> None: linter.register_checker(PackageName(linter)) - linter.register_checker(ImportErrors(linter)) - linter.register_checker(ImportErrorsConanException(linter)) - linter.register_checker(ImportErrorsConanInvalidConfiguration(linter)) linter.register_checker(ImportTools(linter)) linter.register_checker(LayoutSrcFolder(linter)) linter.register_checker(VersionAttribute(linter)) From c9d756b9fa2976605e6d7721eec5337060b261c6 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 19 Sep 2024 12:00:15 +0200 Subject: [PATCH 3/6] Remove lower case name check Signed-off-by: Uilian Ries --- linter/check_package_name.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/linter/check_package_name.py b/linter/check_package_name.py index 4c302243ff26c..fcc8f60447a9b 100644 --- a/linter/check_package_name.py +++ b/linter/check_package_name.py @@ -13,11 +13,6 @@ class PackageName(BaseChecker): name = "conan-package-name" msgs = { - "E9004": ( - "Reference name should be all lowercase", - "conan-bad-name", - "Use only lower-case on the package name: `name = 'foobar'`." - ), "E9005": ( "Missing name attribute", "conan-missing-name", @@ -44,9 +39,6 @@ def visit_classdef(self, node: nodes) -> None: if is_test: self.add_message("conan-test-no-name", node=attr, line=attr.lineno) return - value = children[1].as_string() - if value.lower() != value: - self.add_message("conan-bad-name", node=attr, line=attr.lineno) return if not is_test: self.add_message("conan-missing-name", node=node) From 081ae704e4d3812794ffbc6a7fced93963ae0cac Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 19 Sep 2024 12:06:21 +0200 Subject: [PATCH 4/6] Use Conan 2.x for transition linter Signed-off-by: Uilian Ries --- .github/workflows/linter-conan-v2.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/linter-conan-v2.yml b/.github/workflows/linter-conan-v2.yml index 9b437a26e46d8..769623eebf2c9 100644 --- a/.github/workflows/linter-conan-v2.yml +++ b/.github/workflows/linter-conan-v2.yml @@ -22,12 +22,12 @@ jobs: linter/** .github/workflows/linter-conan-v2.yml - - name: Get Conan v1 version - id: parse_conan_v1_version + - name: Get Conan v2 version + id: parse_conan_v2_version if: steps.changed_files.outputs.any_changed == 'true' uses: mikefarah/yq@master with: - cmd: yq '.conan.version' '.c3i/config_v1.yml' + cmd: yq '.conan.version' '.c3i/config_v2.yml' - uses: actions/setup-python@v4 if: steps.changed_files.outputs.any_changed == 'true' @@ -37,7 +37,7 @@ jobs: - name: Install requirements if: steps.changed_files.outputs.any_changed == 'true' run: | - pip install ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v1_version.outputs.result }} + pip install ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v2_version.outputs.result }} - name: Execute linter over all recipes in the repository id: linter_recipes @@ -68,12 +68,12 @@ jobs: with: files: | recipes/*/*/conanfile.py - - name: Get Conan v1 version - id: parse_conan_v1_version + - name: Get Conan v2 version + id: parse_conan_v2_version if: steps.changed-files.outputs.any_changed == 'true' uses: mikefarah/yq@master with: - cmd: yq '.conan.version' '.c3i/config_v1.yml' + cmd: yq '.conan.version' '.c3i/config_v2.yml' - uses: actions/setup-python@v4 if: steps.changed-files.outputs.any_changed == 'true' with: @@ -81,7 +81,7 @@ jobs: - name: Install dependencies if: steps.changed-files.outputs.any_changed == 'true' run: | - pip install ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v1_version.outputs.result }} + pip install ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v2_version.outputs.result }} - name: Run linter if: steps.changed-files.outputs.any_changed == 'true' run: | @@ -101,12 +101,12 @@ jobs: with: files: | recipes/*/*/test_*/conanfile.py - - name: Get Conan v1 version - id: parse_conan_v1_version + - name: Get Conan v2 version + id: parse_conan_v2_version if: steps.changed-files.outputs.any_changed == 'true' uses: mikefarah/yq@master with: - cmd: yq '.conan.version' '.c3i/config_v1.yml' + cmd: yq '.conan.version' '.c3i/config_v2.yml' - uses: actions/setup-python@v4 if: steps.changed-files.outputs.any_changed == 'true' with: @@ -114,11 +114,11 @@ jobs: - name: Install dependencies if: steps.changed-files.outputs.any_changed == 'true' run: | - pip install ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v1_version.outputs.result }} + pip install ${{ env.REQUIREMENTS }} conan==${{ steps.parse_conan_v2_version.outputs.result }} - name: Run linter if: steps.changed-files.outputs.any_changed == 'true' run: | echo "::add-matcher::linter/recipe_linter.json" for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - pylint --rcfile=linter/pylintrc_testpackage --ignore-paths="recipes/[^/]*/[^/]*/test_v1[^/]*/conanfile.py" --output-format=parseable ${file} + pylint --rcfile=linter/pylintrc_testpackage --ignore-paths="recipes/[^/]*/[^/]*/test_v2[^/]*/conanfile.py" --output-format=parseable ${file} done From 3c2773b60760a006c32d74e3566a6d44f20e88a0 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 19 Sep 2024 12:14:31 +0200 Subject: [PATCH 5/6] Remove old linters from linters doc Signed-off-by: Uilian Ries --- docs/linters.md | 75 ------------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/docs/linters.md b/docs/linters.md index c108d63beb5a0..1a76e25288b80 100644 --- a/docs/linters.md +++ b/docs/linters.md @@ -16,13 +16,8 @@ to configure plugins, warnings and errors which should be enabled or disabled. * [Running the linters locally](#running-the-linters-locally) * [Pylint configuration files](#pylint-configuration-files) * [Linter Warning and Errors](#linter-warning-and-errors) - * [E9006 - conan-import-conanfile: ConanFile should be imported from conan](#e9006---conan-import-conanfile-conanfile-should-be-imported-from-conan) * [E9005 - conan-missing-name: Every conan recipe must contain the attribute name](#e9005---conan-missing-name-every-conan-recipe-must-contain-the-attribute-name) - * [E9004 - conan-package-name: Conan package names must be lower-case](#e9004---conan-package-name-conan-package-names-must-be-lower-case) * [E9007 - conan-test-no-name: Do not add name attribute in test package recipes](#e9007---conan-test-no-name-do-not-add-name-attribute-in-test-package-recipes) - * [E9008 - conan-import-errors: Deprecated imports should be replaced by new imports](#e9008---conan-import-errors-deprecated-imports-should-be-replaced-by-new-imports) - * [E9009 - conan-import-error-conanexception: conans.errors is deprecated and conan.errors should be used instead](#e9009---conan-import-error-conanexception-conanserrors-is-deprecated-and-conanerrors-should-be-used-instead) - * [E9010 - conan-import-error-conaninvalidconfiguration: conans.errors is deprecated and conan.errors should be used instead](#e9010---conan-import-error-conaninvalidconfiguration-conanserrors-is-deprecated-and-conanerrors-should-be-used-instead) * [E9011 - conan-import-tools: Importing conan.tools or conan.tools.xxx.zzz.yyy should be considered as private](#e9011---conan-import-tools-importing-conantools-or-conantoolsxxxzzzyyy-should-be-considered-as-private) * [E9012 - conan-attr-version: Recipe should not contain version attribute](#e9012---conan-attr-version-recipe-should-not-contain-version-attribute) @@ -47,18 +42,6 @@ Check the [Developing Recipes](developing_recipes_locally.md) for more informati Here is the list of current warning and errors provided by pylint, when using CCI configuration. -### E9006 - conan-import-conanfile: ConanFile should be imported from conan - -```python -from conans import ConanFile -``` - -Should be replaced by: - -```python -from conan import Conanfile -``` - ### E9005 - conan-missing-name: Every conan recipe must contain the attribute name The attribute `name` is always expected. On the other hand, `version` should not be listed. @@ -68,15 +51,6 @@ def BazConanfile(ConanFile): name = "baz" ``` -### E9004 - conan-package-name: Conan package names must be lower-case - -The package name is always lower-case, even when the upstream uses another format - -```python -def FoobarConanfile(ConanFile): - name = "foobar" -``` - ### E9007 - conan-test-no-name: Do not add name attribute in test package recipes The test package is not a recipe, thus, it should not have a name @@ -86,55 +60,6 @@ def TestPackageConanFile(ConanFile): name = "test_package" # Wrong! ``` -### E9008 - conan-import-errors: Deprecated imports should be replaced by new imports - -Read [v2_linter](v2_linter.md) for a list of mappings of v1 to v2. -Regular imports from `conans.tools` are now updated: - -```python -from conans import tools -... - -tools.rmdir(os.path.join(self.package_folder, "shared")) -``` - -Should be replaced by specialized tools, prepared for Conan 2.0 - -```python -from conan.tools.files import rmdir -... - -rmdir(self, os.path.join(self.package_folder, "shared")) -``` - -### E9009 - conan-import-error-conanexception: conans.errors is deprecated and conan.errors should be used instead - -```python -from conans.errors import ConanException -``` - -Should be replaced by: - -```python -from conan.errors import ConanException -``` - -Only the namespace `conans` has been replaced by `conan`. - -### E9010 - conan-import-error-conaninvalidconfiguration: conans.errors is deprecated and conan.errors should be used instead - -```python -from conans.errors import ConanInvalidConfiguration -``` - -Should be replaced by: - -```python -from conan.errors import ConanInvalidConfiguration -``` - -Only the namespace `conans` has been replaced by `conan`. - ### E9011 - conan-import-tools: Importing conan.tools or conan.tools.xxx.zzz.yyy should be considered as private Documented on [conanfile.tools](https://docs.conan.io/1/reference/conanfile/tools.html): From 2a0544a5e36fba12106340599cfc643fbd0513cb Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 19 Sep 2024 12:19:57 +0200 Subject: [PATCH 6/6] Conan 2.x is mandatory Signed-off-by: Uilian Ries --- docs/v2_migration.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/v2_migration.md b/docs/v2_migration.md index 9139fefbde135..d372401b811e0 100644 --- a/docs/v2_migration.md +++ b/docs/v2_migration.md @@ -3,8 +3,8 @@ This is expected for recipes to be updates in each pull request. - Updated helpers are expected, this is enforced by the [v2_linter](v2_linter.md) -- Once a recipe publishes v2 packages, it must pass the v2 pipeline -- The v2 pipeline with **shortly be required** for changes to be merged. +- Once a recipe publishes v2 packages, it must pass the v2 pipeline always. +- The v2 pipeline with **is required** for changes to be merged. ## Contents @@ -127,7 +127,7 @@ generators using the ``set_property(property_name, value)`` method. Both of these two models **will live together in recipes** to make recipes compatible for both 1.x and 2.0 users. Deprecated feilds are not to be removed at this time. -To understand the impact of these and the relation between different generates, refer to the +To understand the impact of these and the relation between different generates, refer to the [migrating properties](https://docs.conan.io/1/migrating_to_2.0/properties.html) documentation. ### Translating .names information to cmake_target_name, cmake_module_target_name and cmake_file_name