Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linter] reduce pylint to just one command #15115

Merged
merged 4 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions linter/check_no_test_package_name.py

This file was deleted.

17 changes: 15 additions & 2 deletions linter/check_package_name.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pylint.checkers import BaseChecker
from pylint.interfaces import IAstroidChecker
from astroid import nodes, Const, AssignName
from pathlib import Path


class PackageName(BaseChecker):
Expand All @@ -21,19 +22,31 @@ class PackageName(BaseChecker):
"Missing name attribute",
"conan-missing-name",
"The member attribute `name` must be declared: `name = 'foobar'`."
)
),
"E9007": (
"No 'name' attribute in test_package conanfile",
"conan-test-no-name",
"No 'name' attribute in test_package conanfile."
),
}

def visit_classdef(self, node: nodes) -> None:
filename = Path(node.root().file)
is_test = filename.match('test_package/*.py') or filename.match('test_v1_package/*.py')

if node.basenames == ['ConanFile']:
for attr in node.body:
children = list(attr.get_children())
if len(children) == 2 and \
isinstance(children[0], AssignName) and \
children[0].name == "name" and \
isinstance(children[1], Const):
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
self.add_message("conan-missing-name", node=node)
if not is_test:
self.add_message("conan-missing-name", node=node)
20 changes: 0 additions & 20 deletions linter/conanv2_test_transition.py

This file was deleted.

3 changes: 2 additions & 1 deletion linter/pylintrc_testpackage
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[MASTER]
load-plugins=linter.conanv2_test_transition,
load-plugins=linter.conanv2_transition,
linter.transform_conanfile,
linter.transform_imports

py-version=3.6
recursive=no
suggestion-mode=yes
Expand Down