Skip to content

approx: expose pytest.Approx as the return type of pytest.approx#14647

Open
bluetech wants to merge 7 commits into
pytest-dev:mainfrom
bluetech:approx-typing
Open

approx: expose pytest.Approx as the return type of pytest.approx#14647
bluetech wants to merge 7 commits into
pytest-dev:mainfrom
bluetech:approx-typing

Conversation

@bluetech

Copy link
Copy Markdown
Member

As requested in #14164 (part of #7469).

There are some initial commits that are prerequisites or small cleanups/refactors to the code.

bluetech added 7 commits June 23, 2026 14:30
I don't think it has any effect (always False, checked two lines above).
Probably a copy/paste error.
Consistently use `_is_bool` check which handles `numpy.bool` in addition
to `bool`, instead of `isinstance(..., bool)`.
The code is more direct this way, and more amenable to typing (in follow
up commits).
Not really helpful and annoying to type.
This (tries to) improve the typing of the approx code in preparation of
exposing a type for its return value.

The main change is to make `ApproxBase` generic in the expected value
type, so that `self.expected` can have a correct type. This is not so
easy...
The `python_api.py` file used to also contain the implementation of
`raises`, but that was moved to its own file a while ago. Now
`python_api.py` only houses the `approx` code, so let's rename it to the
more obvious and less generic `approx.py`.
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant