support pytest
pylance:
from pytest import fixture
@fixture()
def f() -> int:
return 1
def test_asdf(f):
reveal_type(f) # Any
This is of course absolutely insane that it's Any.
I don't know the best way to handle this, via a plugin?
blocked by #22
i dont want to special-case specific modules if i can help it, especially 3rd party ones, so i don't really want to do this without a plugin system
With pytest 8.3.2 and bpr 1.16.0 I get Type of "f" is "int" with
from pytest import fixture
from typing_extensions import reveal_type
@fixture()
def f() -> int:
return 1
def test_asdf(f: int):
reveal_type(f)
so no Anymore 🤷🏻♂️
sorry the example in the original post is a bit confusing. this part with the type annotation in backticks was just pseudocode we came up with to say that it should infer f as int and show it as an inlay hint:
def test_asdf(f`: int`):
reveal_type(f)
i updated that example to remove that part because i don't think this is really relevant to inlay hints. the inlay hint support is implied (as in, once we have pytest support and f gets inferred as int, the inlay hint will come naturally)
@fixture()
def f() -> int:
return 1
def test_asdf(f): # no type annotation should be needed, it should just infer it as int
reveal_type(f) # int
once #336 is resolved we also want to disable reportUnusedParameter on pytest hookspecs (related: https://github.com/astral-sh/ruff/issues/9803)