Skip to content

support plugins as a classΒ #11300

Open
Open
@DetachHead

Description

@DetachHead

What's the problem this feature will solve?

currently, there is no way to type check your hook functions:

from pytest import Item

def pytest_runtestloop(session: Item): # no type error, it should be Session
    ...

Describe the solution you'd like

expose a base class for plugins to extend, so they can be defined like so:

from typing_extensions import override
from pytest import Plugin

class SomePlugin(Plugin):
    @override
    def pytest_runtestloop(self, session: Item): # type error: signature does not match base method
        ...

Alternative Solutions

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: typingtype-annotation issuetype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions