diff options
author | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-09-29 14:33:29 +0200 |
---|---|---|
committer | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-09-29 20:29:37 +0200 |
commit | 8c74530e677ad2e8332f5ab0e7e64516571aae40 (patch) | |
tree | 0f272a4bc8d294855938b31607c81b7cc0559673 | |
parent | 118c91972562058d85d09cb64537b8c383556790 (diff) | |
download | pylint-git-8c74530e677ad2e8332f5ab0e7e64516571aae40.tar.gz |
Fix empty regex options not converting to regex
-rw-r--r-- | pylint/config/option.py | 2 | ||||
-rw-r--r-- | pylint/utils/utils.py | 6 | ||||
-rw-r--r-- | tests/extensions/test_check_docs.py | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/pylint/config/option.py b/pylint/config/option.py index 5b4ae2eb2..0a9a37069 100644 --- a/pylint/config/option.py +++ b/pylint/config/option.py @@ -78,7 +78,7 @@ VALIDATORS = { "string": utils._unquote, "int": int, "float": float, - "regexp": re.compile, + "regexp": lambda pattern: re.compile(pattern or ""), "regexp_csv": _regexp_csv_validator, "csv": _csv_validator, "yn": _yn_validator, diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index 3843451d4..d8d4baf0a 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -65,7 +65,7 @@ GLOBAL_OPTION_NAMES = Union[ GLOBAL_OPTION_TUPLE_INT, ] T_GlobalOptionReturnTypes = TypeVar( - "T_GlobalOptionReturnTypes", bool, int, List[str], Pattern, Tuple[int, ...] + "T_GlobalOptionReturnTypes", bool, int, List[str], Pattern[str], Tuple[int, ...] ) @@ -215,8 +215,8 @@ def get_global_option( def get_global_option( checker: "BaseChecker", option: GLOBAL_OPTION_PATTERN, - default: Optional[Pattern] = None, -) -> Pattern: + default: Optional[Pattern[str]] = None, +) -> Pattern[str]: ... diff --git a/tests/extensions/test_check_docs.py b/tests/extensions/test_check_docs.py index 65d077aed..1c250bc9b 100644 --- a/tests/extensions/test_check_docs.py +++ b/tests/extensions/test_check_docs.py @@ -25,6 +25,8 @@ in particular the parameter documentation checker `DocstringChecker` # pylint: disable=too-many-public-methods +import re + import astroid import pytest from astroid import nodes @@ -2325,7 +2327,7 @@ class TestParamDocChecker(CheckerTestCase): ): self.checker.visit_functiondef(node) - @set_config_directly(no_docstring_rgx=r"^_(?!_).*$") + @set_config_directly(no_docstring_rgx=re.compile(r"^_(?!_).*$")) def test_skip_no_docstring_rgx(self) -> None: """Example of a function that matches the default 'no-docstring-rgx' config option |