Merge pull request #736 from cjmayo/pylint

Fix errors found by Pylint
This commit is contained in:
Chris Mayo 2023-05-08 19:24:03 +01:00 committed by GitHub
commit 6ada5d9517
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 29 additions and 11 deletions

View file

@ -149,6 +149,8 @@ jobs:
matrix:
toxenv:
- flake8
- check-python-versions
- pylint
- yamllint
steps:

5
.pylintrc Normal file
View file

@ -0,0 +1,5 @@
[TYPECHECK]
ignored-modules=meliae, win32com.client, yappi
[VARIABLES]
additional-builtins=_, _n

View file

@ -234,9 +234,7 @@ def better_exchook(etype, value, tb, out=sys.stdout):
else:
line = f"{etype}: {valuestr}"
return line
if (isinstance(etype, BaseException) or
(hasattr(types, "InstanceType") and isinstance(etype, types.InstanceType)) or
etype is None or type(etype) is str):
if isinstance(etype, BaseException) or etype is None or type(etype) is str:
output(_format_final_exc_line(etype, value), out=out)
else:
output(_format_final_exc_line(etype.__name__, value), out=out)

View file

@ -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()

View file

@ -26,6 +26,7 @@ import requests
import warnings
warnings.simplefilter(
# pylint: disable=no-member
'ignore', requests.packages.urllib3.exceptions.InsecureRequestWarning
)

View file

@ -16,6 +16,8 @@
"""
Base URL handler.
"""
# pylint: disable=assignment-from-none, catching-non-exception, no-member
import sys
import os
import urllib.parse

View file

@ -397,9 +397,8 @@ class ArgParser(LCArgumentParser):
group.add_argument(
"-p",
"--password",
action="store_false",
action="store_true",
dest="password",
default=False,
help=_(
"Read a password from console and use it for HTTP and FTP authorization.\n"
"For FTP the default password is 'anonymous@'. For HTTP there is\n"

View file

@ -28,7 +28,6 @@ from .. import LOG_CMDLINE
from .. import get_link_pat, log
from ..cmdline import print_version, print_usage, print_plugins
from ..director import console
def has_encoding(encoding):
@ -164,7 +163,7 @@ def setup_config(config, options):
}
else:
msg = _("Enter LinkChecker HTTP/FTP password:")
_password = getpass.getpass(console.encode(msg))
_password = getpass.getpass(msg)
constructauth = True
if options.quiet:
config["logger"] = config.logger_new("none")

View file

@ -304,8 +304,7 @@ class Configuration(dict):
def sanitize_ssl(self):
"""Use local installed certificate file if available.
Tries to get system, then certifi, then the own
installed certificate file."""
Tries to get system, then certifi certificate file."""
if self["sslverify"] is True:
try:
self["sslverify"] = get_system_cert_file()

View file

@ -138,7 +138,7 @@ class WordParser(_ParserPlugin):
raise Error("could not open word file %r" % filename)
try:
for link in doc.Hyperlinks:
line = get_line_number(link.Range)
line = get_line_number(doc, link.Range)
name = link.TextToDisplay
url_data.add_url(link.Address, name=name, line=line)
finally:

View file

@ -16,6 +16,7 @@
"""
Test dummy object.
"""
# pylint: disable=no-member, not-callable
import unittest

12
tox.ini
View file

@ -28,6 +28,18 @@ deps = flake8
skip_install = true
commands = flake8 {posargs}
[testenv:check-python-versions]
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