Skip to content

Commit

Permalink
Upgrade pylint to be able to run hyperstyle on projects
Browse files Browse the repository at this point in the history
  • Loading branch information
nbirillo committed Sep 5, 2023
1 parent f0d4110 commit ee075c1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.3
1.4.4
3 changes: 3 additions & 0 deletions hyperstyle/src/python/review/inspectors/pylint/pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
BASE_COMMAND = [
'pylint',
'--load-plugins', 'pylint_django',
# TODO: ask about django settings via an cli argument?
'--disable=django-not-configured',
f'--rcfile={PATH_PYLINT_CONFIG}',
f'--msg-template={MSG_TEMPLATE}',
'--recursive=true'
]


Expand Down
3 changes: 3 additions & 0 deletions hyperstyle/src/python/review/inspectors/pylint/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ disable=invalid-name,
W0614,
W0622,
W0511,
R1718, # conflicts with R1735
R1717, # conflicts with R1734


# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
setuptools==56.0.0

# python code analysis tools
pylint==2.7.4
pylint-django==2.3.0
pylint==2.13.0
pylint-django==2.5.3
flake8==3.9.0

# flake8 plugins
Expand All @@ -25,6 +25,6 @@ cohesion==1.0.0
radon==4.5.0

# extra libraries and frameworks
django==3.2
django==4.2.5
requests==2.25.1
argparse==1.4.0
14 changes: 14 additions & 0 deletions test/python/inspectors/test_pylint_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@
]


FOLDER_NAMES_AND_N_ISSUES = [
('case0_folder_without_init', 0),
]


@pytest.mark.parametrize(('folder_name', 'n_issues'), FOLDER_NAMES_AND_N_ISSUES)
def test_folder_with_issues(folder_name: str, n_issues: int):
inspector = PylintInspector()
path_to_folder = PYTHON_DATA_FOLDER / folder_name
issues = inspector.inspect(path_to_folder, {})

assert len(issues) == n_issues


@pytest.mark.parametrize(('file_name', 'n_issues'), FILE_NAMES_AND_N_ISSUES)
def test_file_with_issues(file_name: str, n_issues: int):
inspector = PylintInspector()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if __name__ == '__main__':
print('hello world!')
2 changes: 1 addition & 1 deletion test/resources/inspectors/python/case4_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, a, b, C):
self.C = C

def myFun(self):
print('hello 1')
print(f'hello 1 {self.A}')

def my_fun(self, QQ):
print('hello 2 {}'.format(QQ))
Expand Down

0 comments on commit ee075c1

Please sign in to comment.