Skip to content
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

Consider exporting MonkeyPatch to enable type hints #2712

Closed
CaselIT opened this issue Aug 22, 2017 · 6 comments
Closed

Consider exporting MonkeyPatch to enable type hints #2712

CaselIT opened this issue Aug 22, 2017 · 6 comments
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@CaselIT
Copy link

CaselIT commented Aug 22, 2017

I would like to use type hints for the monkeypatch fixture, but the class MonkeyPatch is not exported by pytest, so at the moment it needs to be imported from the internal package _pytest.

Example:

from pytest import MonkeyPatch 

def test_something(monkeypatch: MonkeyPatch):
    # monkeypatch has type hints here if the IDE supports them
    monkeypatch.delattr(...)
@RonnyPfannschmidt
Copy link
Member

currently we dont export internal classes, and deciding which internal interfaces to export will be a really interesting future experience

@CaselIT
Copy link
Author

CaselIT commented Aug 22, 2017

Is it because MonkeyPatch should not be instantiated directly, or just to avoid polluting the pytest module?
Maybe they could be exposed in an interfaces module (or similar) so they can be imported with from pytest.interfaces import MonkeyPatch

@nicoddemus
Copy link
Member

It it because MonkeyPatch should not be instantiated directly, or just to avoid polluting the pytest module?

The latter, specially regarding the name of the class and the API to initialize it.

Alternatively I remember that it was possible to provide some .pyi files instead (or something similar). I wonder if this would solve this problem as well.

@CaselIT
Copy link
Author

CaselIT commented Aug 22, 2017

@nicoddemus Thanks for the clarification.

I'm not familiar with how the strub files work. I'll try look into it.

@nicoddemus nicoddemus added the type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature label Aug 23, 2017
@Zac-HD
Copy link
Member

Zac-HD commented Dec 7, 2018

Closing as obsoleted by discussion in #3342.

@Zac-HD Zac-HD closed this as completed Dec 7, 2018
@CaselIT
Copy link
Author

CaselIT commented Dec 7, 2018

I'll follow the other issue then. Thanks for the heads-up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

4 participants