From e6da68b7f6e9c3c1486dc3cf3eb051bf4e5745af Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Wed, 3 May 2023 19:24:53 +0100 Subject: [PATCH] Add linting with Pylint to build workflow --- .github/workflows/build.yml | 1 + .pylintrc | 5 +++++ linkcheck/checker/const.py | 2 +- linkcheck/checker/httpurl.py | 1 + linkcheck/checker/urlbase.py | 2 ++ tests/test_dummy.py | 1 + tox.ini | 7 +++++++ 7 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .pylintrc diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef37f465..5bfc8740 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,6 +150,7 @@ jobs: toxenv: - flake8 - check-python-versions + - pylint - yamllint steps: diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..8f5a8fcf --- /dev/null +++ b/.pylintrc @@ -0,0 +1,5 @@ +[TYPECHECK] +ignored-modules=meliae, win32com.client, yappi + +[VARIABLES] +additional-builtins=_, _n diff --git a/linkcheck/checker/const.py b/linkcheck/checker/const.py index c5d3fe9e..ee55d04e 100644 --- a/linkcheck/checker/const.py +++ b/linkcheck/checker/const.py @@ -41,7 +41,7 @@ ExcCacheList = [ EOFError, # http errors requests.exceptions.RequestException, - requests.packages.urllib3.exceptions.HTTPError, + requests.packages.urllib3.exceptions.HTTPError, # pylint: disable=no-member # ftp errors ftplib.Error, # idna.encode(), called from socket.create_connection() diff --git a/linkcheck/checker/httpurl.py b/linkcheck/checker/httpurl.py index 40392a44..eb55b719 100644 --- a/linkcheck/checker/httpurl.py +++ b/linkcheck/checker/httpurl.py @@ -26,6 +26,7 @@ import requests import warnings warnings.simplefilter( + # pylint: disable=no-member 'ignore', requests.packages.urllib3.exceptions.InsecureRequestWarning ) diff --git a/linkcheck/checker/urlbase.py b/linkcheck/checker/urlbase.py index 1a1cdcaa..58212890 100644 --- a/linkcheck/checker/urlbase.py +++ b/linkcheck/checker/urlbase.py @@ -16,6 +16,8 @@ """ Base URL handler. """ +# pylint: disable=assignment-from-none, catching-non-exception, no-member + import sys import os import urllib.parse diff --git a/tests/test_dummy.py b/tests/test_dummy.py index bdf4e559..38bd92d0 100644 --- a/tests/test_dummy.py +++ b/tests/test_dummy.py @@ -16,6 +16,7 @@ """ Test dummy object. """ +# pylint: disable=no-member, not-callable import unittest diff --git a/tox.ini b/tox.ini index 9dbc56ac..eb8dc7d5 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,13 @@ deps = check-python-versions skip_install = true commands = check-python-versions {posargs} +[testenv:pylint] +deps = + pylint + -rrequirements.txt +skip_install = true +commands = pylint {posargs} -E linkcheck + [testenv:yamllint] deps = yamllint skip_install = true