Skip to content

Commit

Permalink
(conan-io#15115) [linter] reduce pylint to just one command
Browse files Browse the repository at this point in the history
* determine test_package folder in the lint rule

* delete old test specific linter config + update github workflow

* fixup: put bad specific config

---------

Co-authored-by: Chris Mc <christopherm@jfrog.com>
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
  • Loading branch information
3 people authored and franramirez688 committed May 10, 2023
1 parent 33cdffe commit 700807c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 53 deletions.
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

0 comments on commit 700807c

Please sign in to comment.