summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2021-09-25 13:28:08 +0200
committerGitHub <noreply@github.com>2021-09-25 13:28:08 +0200
commit2c0e27330f494856799de9fd9cfb02fa71dacf27 (patch)
tree68090bdfad47cf5208329e7c2dbb77a8fe7a90aa
parentae4e39e986acf73f78b52422c902bcd28cbd985f (diff)
downloadpylint-git-2c0e27330f494856799de9fd9cfb02fa71dacf27.tar.gz
Small py-version improvements (#5069)
* Add py-version requirement to checker docs * Improve default value * Improve option parser error message * Fix py-version help text
-rw-r--r--pylint/checkers/refactoring/recommendation_checker.py2
-rw-r--r--pylint/config/option.py4
-rw-r--r--pylint/extensions/code_style.py2
-rw-r--r--pylint/utils/utils.py2
4 files changed, 6 insertions, 4 deletions
diff --git a/pylint/checkers/refactoring/recommendation_checker.py b/pylint/checkers/refactoring/recommendation_checker.py
index 7e8abcb7e..81a7dd7b1 100644
--- a/pylint/checkers/refactoring/recommendation_checker.py
+++ b/pylint/checkers/refactoring/recommendation_checker.py
@@ -58,7 +58,7 @@ class RecommendationChecker(checkers.BaseChecker):
"consider-using-f-string",
"Used when we detect a string that is being formatted with format() or % "
"which could potentially be a f-string. The use of f-strings is preferred. "
- "Requires Python 3.6",
+ "Requires Python 3.6 and ``py-version >= 3.6``.",
),
}
diff --git a/pylint/config/option.py b/pylint/config/option.py
index eb5890896..078c638d3 100644
--- a/pylint/config/option.py
+++ b/pylint/config/option.py
@@ -68,7 +68,9 @@ def _py_version_validator(_, name, value):
try:
value = tuple(int(val) for val in value.split("."))
except (ValueError, AttributeError):
- raise optparse.OptionValueError(f"Invalid format for {name}") from None
+ raise optparse.OptionValueError(
+ f"Invalid format for {name}, should be version string. E.g., '3.8'"
+ ) from None
return value
diff --git a/pylint/extensions/code_style.py b/pylint/extensions/code_style.py
index aeb185765..8d789720a 100644
--- a/pylint/extensions/code_style.py
+++ b/pylint/extensions/code_style.py
@@ -53,7 +53,7 @@ class CodeStyleChecker(BaseChecker):
"consider-using-assignment-expr",
"Emitted when an if assignment is directly followed by an if statement and "
"both can be combined by using an assignment expression ``:=``. "
- "Requires Python 3.8",
+ "Requires Python 3.8 and ``py-version >= 3.8``.",
),
}
options = (
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py
index fc89bbacd..3843451d4 100644
--- a/pylint/utils/utils.py
+++ b/pylint/utils/utils.py
@@ -131,7 +131,7 @@ def get_rst_section(section, options, doc=None):
if help_opt:
formatted_help = normalize_text(help_opt, indent=" ")
result += f"{formatted_help}\n"
- if value:
+ if value and optname != "py-version":
value = str(_format_option_value(optdict, value))
result += f"\n Default: ``{value.replace('`` ', '```` ``')}``\n"
return result