From edb6211e3692974dc2b0984d71483f3296fcef3f Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 29 Jul 2020 11:49:41 +0300 Subject: [PATCH 1/2] Merge pull request #7565 from bluetech/pylint-callable-2 mark: fix pylint not-callable error on pytest.mark.parametrize(...), again (cherry picked from commit f9837f953c03268baa4ae8e9803cb3a13ec6860c) --- changelog/7558.bugfix.rst | 2 ++ src/_pytest/mark/structures.py | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 changelog/7558.bugfix.rst diff --git a/changelog/7558.bugfix.rst b/changelog/7558.bugfix.rst new file mode 100644 index 000000000..6e3ec674c --- /dev/null +++ b/changelog/7558.bugfix.rst @@ -0,0 +1,2 @@ +Fix pylint ``not-callable`` lint on ``pytest.mark.parametrize()`` and the other builtin marks: +``skip``, ``skipif``, ``xfail``, ``usefixtures``, ``filterwarnings``. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 5edeecdd5..9f8ce4ebc 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -4,7 +4,6 @@ import typing import warnings from typing import Any from typing import Callable -from typing import cast from typing import Iterable from typing import List from typing import Mapping @@ -473,14 +472,13 @@ class MarkGenerator: # See TYPE_CHECKING above. if TYPE_CHECKING: - # Using casts instead of type comments intentionally - issue #7473. # TODO(py36): Change to builtin annotation syntax. - skip = cast(_SkipMarkDecorator, None) - skipif = cast(_SkipifMarkDecorator, None) - xfail = cast(_XfailMarkDecorator, None) - parametrize = cast(_ParametrizeMarkDecorator, None) - usefixtures = cast(_UsefixturesMarkDecorator, None) - filterwarnings = cast(_FilterwarningsMarkDecorator, None) + skip = _SkipMarkDecorator(Mark("skip", (), {})) + skipif = _SkipifMarkDecorator(Mark("skipif", (), {})) + xfail = _XfailMarkDecorator(Mark("xfail", (), {})) + parametrize = _ParametrizeMarkDecorator(Mark("parametrize ", (), {})) + usefixtures = _UsefixturesMarkDecorator(Mark("usefixtures ", (), {})) + filterwarnings = _FilterwarningsMarkDecorator(Mark("filterwarnings ", (), {})) def __getattr__(self, name: str) -> MarkDecorator: if name[0] == "_": From bec1bdaa2cf53bc6213a106edec1131287adc22d Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 29 Jul 2020 11:58:54 +0300 Subject: [PATCH 2/2] mark: fix extraneous spaces in dummy type-checking marks (cherry picked from commit 54e08b72304908b0cddb1ec68c297815cbd7f757) --- src/_pytest/mark/structures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 9f8ce4ebc..656782299 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -476,9 +476,9 @@ class MarkGenerator: skip = _SkipMarkDecorator(Mark("skip", (), {})) skipif = _SkipifMarkDecorator(Mark("skipif", (), {})) xfail = _XfailMarkDecorator(Mark("xfail", (), {})) - parametrize = _ParametrizeMarkDecorator(Mark("parametrize ", (), {})) - usefixtures = _UsefixturesMarkDecorator(Mark("usefixtures ", (), {})) - filterwarnings = _FilterwarningsMarkDecorator(Mark("filterwarnings ", (), {})) + parametrize = _ParametrizeMarkDecorator(Mark("parametrize", (), {})) + usefixtures = _UsefixturesMarkDecorator(Mark("usefixtures", (), {})) + filterwarnings = _FilterwarningsMarkDecorator(Mark("filterwarnings", (), {})) def __getattr__(self, name: str) -> MarkDecorator: if name[0] == "_":