Improve pylintrc.

- Move it to `auxprogs/`, alongside `pybuild.sh`.
- Disable the annoying design lints, instead of just modifying the
  values (which often requires modifying them again later).
This commit is contained in:
Nicholas Nethercote
2023-04-06 09:25:15 +10:00
parent 1db98dbdb1
commit 81c7be88b2
5 changed files with 37 additions and 61 deletions

View File

@@ -44,8 +44,9 @@ set -e
ver=3.9
pyver=py39
infile=$1
outfile=$2
auxprogs=$1
infile=$2
outfile=$3
if [ -z "$outfile" ] ; then
exit 1
fi
@@ -80,7 +81,7 @@ ruff check --target-version $pyver $infile
echo
echo "== pylint =="
pylint --py-version $ver $infile
pylint --rcfile=$auxprogs/pylintrc --py-version $ver $infile
echo "== config.status =="
make $outfile

28
auxprogs/pylintrc Normal file
View File

@@ -0,0 +1,28 @@
# How to create this file.
# - Generate with `pylint --generate-rcfile > pylintrc`. Do this in a directory
# that doesn't already contain a `pylintrc` file, because the output is
# affected by any existing `pylintrc` file.
# - Then modify entries resulting in unreasonable warnings.
# - If a lint is never interesting, add it to the `disable=` list with an
# explanatory comment.
# - If a lint is interesting but needs modification, comment out the original
# value, add a new value along with an explanatory comment.
# - Remove all non-modified entries.
[MESSAGES CONTROL]
disable=
# We don't care about having docstrings for all functions/classes.
missing-class-docstring, missing-function-docstring,
# We don't care about large functions, sometimes it's necessary.
too-many-branches, too-many-locals, too-many-statements,
# Zero or one public methods in a class is fine.
too-few-public-methods,
[BASIC]
# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
#good-names-rgxs=
# We allow any lower-case variable name of length 1 or 2.
good-names-rgxs=\b[a-z]\b,\b[a-z][a-z0-9]\b

View File

@@ -76,14 +76,14 @@ endif
# "Build" `cg_annotate`. The `+` avoids warnings about the jobserver.
pyann:
+../auxprogs/pybuild.sh cg_annotate.in cg_annotate
+../auxprogs/pybuild.sh ../auxprogs cg_annotate.in cg_annotate
# "Build" `cg_diff`. The `+` avoids warnings about the jobserver.
pydiff:
+../auxprogs/pybuild.sh cg_diff.in cg_diff
+../auxprogs/pybuild.sh ../auxprogs cg_diff.in cg_diff
# "Build" `cg_merge`. The `+` avoids warnings about the jobserver.
pymerge:
+../auxprogs/pybuild.sh cg_merge.in cg_merge
+../auxprogs/pybuild.sh ../auxprogs cg_merge.in cg_merge
.PHONY: pyann pydiff pymerge

View File

@@ -73,7 +73,7 @@ class Args(Namespace):
raise ValueError
def add_bool_argument(
p: ArgumentParser, new_name: str, old_name: str, help: str
p: ArgumentParser, new_name: str, old_name: str, help_: str
) -> None:
"""
Add a bool argument that defaults to true.
@@ -92,7 +92,7 @@ class Args(Namespace):
new_flag,
default=True,
action=BooleanOptionalAction,
help=help,
help=help_,
)
p.add_argument(
f"{old_flag}=yes",

View File

@@ -1,53 +0,0 @@
# How to create this file.
# - Generate with `pylint --generate-rcfile > pylintrc`.
# - Then modify entries resulting in unreasonable warnings. Comment out the
# original value, and add another comment line explaining the modification.
# - Remove all non-modified entries.
[BASIC]
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
#docstring-min-length=-1
# We don't care about having docstrings for all functions/classes.
docstring-min-length=1000
# Good variable names regexes, separated by a comma. If names match any regex,
# they will always be accepted
#good-names-rgxs=
# We allow any lower-case variable name of length 1 or 2.
good-names-rgxs=\b[a-z]\b,\b[a-z][a-z0-9]\b
[VARIABLES]
# List of names allowed to shadow builtins
#allowed-redefined-builtins=
# We use `help` reasonably as an argument.
allowed-redefined-builtins=help
[DESIGN]
# Maximum number of arguments for function / method.
#max-args=5
# We have some large functions.
max-args=7
# Maximum number of branch for function / method body.
#max-branches=12
# We have some large functions.
max-branches=25
# Maximum number of locals for function / method body.
#max-locals=15
# We have some large functions.
max-locals=25
# Maximum number of statements in function / method body.
#max-statements=50
# We have some large functions.
max-statements=65
# Minimum number of public methods for a class (see R0903).
#min-public-methods=2
# We have some useful classes with little more than `__init__`.
min-public-methods=0