Skip to content

[6.0.x] mark: fix pylint not-callable error on pytest.mark.parametrize(...), again #7566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/7558.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix pylint ``not-callable`` lint on ``pytest.mark.parametrize()`` and the other builtin marks:
``skip``, ``skipif``, ``xfail``, ``usefixtures``, ``filterwarnings``.
14 changes: 6 additions & 8 deletions src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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
Expand Down Expand Up @@ -473,14 +472,13 @@ def test_function():

# 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 ", (), {}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parametrize = _ParametrizeMarkDecorator(Mark("parametrize ", (), {}))
usefixtures = _UsefixturesMarkDecorator(Mark("usefixtures ", (), {}))
filterwarnings = _FilterwarningsMarkDecorator(Mark("filterwarnings ", (), {}))
parametrize = _ParametrizeMarkDecorator(Mark("parametrize", (), {}))
usefixtures = _UsefixturesMarkDecorator(Mark("usefixtures", (), {}))
filterwarnings = _FilterwarningsMarkDecorator(Mark("filterwarnings", (), {}))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth fixing this before the backport

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I am going to fix in master and add the backport of that as well to this PR.


def __getattr__(self, name: str) -> MarkDecorator:
if name[0] == "_":
Expand Down