Skip to content

6.0.0rc1 pytest.fixture mypy error: Value of type "object" is not indexable #7494

@simonjayhawkins

Description

@simonjayhawkins
  • a detailed description of the bug or suggestion
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible
# file: pytest-mypy.py
import pytest


@pytest.fixture(params=[(0, 0), (1, 1)], ids=lambda x: x[0])
def b(request):
    return request.param


def test_b(b):
    pass
$ pytest ~/pytest-mypy.py -vv
=========================================================================== test session starts ============================================================================
platform win32 -- Python 3.8.3, pytest-6.0.0rc1, py-1.9.0, pluggy-0.13.1 -- c:\users\simon\anaconda3\envs\pandas-dev\python.exe
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('C:\\Users\\simon\\pandas\\.hypothesis\\examples')
rootdir: C:\Users\simon
plugins: hypothesis-5.16.3, asyncio-0.12.0, cov-2.10.0, forked-1.1.2, xdist-1.32.0
collected 2 items

..\pytest-mypy.py::test_b[0] PASSED                                                                                                                                   [ 50%]
..\pytest-mypy.py::test_b[1] PASSED                                                                                                                                   [100%]

============================================================================ 2 passed in 0.17s =============================================================================
$ mypy ~/pytest-mypy.py
C:\Users\simon\pytest-mypy.py:4: error: Value of type "object" is not indexable
Found 1 error in 1 file (checked 1 source file)

the type annotation for ids in fixture is

    ids: Optional[
        Union[
            Iterable[Union[None, str, float, int, bool]],
            Callable[[object], Optional[object]],
        ]
    ] = None,

i believe that the Callable should accept Any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions