diff options
author | Marc Mueller <30130371+cdce8p@users.noreply.github.com> | 2021-09-25 13:28:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-25 13:28:08 +0200 |
commit | 2c0e27330f494856799de9fd9cfb02fa71dacf27 (patch) | |
tree | 68090bdfad47cf5208329e7c2dbb77a8fe7a90aa | |
parent | ae4e39e986acf73f78b52422c902bcd28cbd985f (diff) | |
download | pylint-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.py | 2 | ||||
-rw-r--r-- | pylint/config/option.py | 4 | ||||
-rw-r--r-- | pylint/extensions/code_style.py | 2 | ||||
-rw-r--r-- | pylint/utils/utils.py | 2 |
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 |