Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

A pytest plugin to assert type annotations at runtime.

Notifications You must be signed in to change notification settings

untitaker/pytest-fixture-typecheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pytest-fixture-typecheck

https://img.shields.io/pypi/v/pytest-fixture-typecheck https://img.shields.io/pypi/l/pytest-fixture-typecheck

pytest-fixture-typecheck is a pytest plugin that inserts runtime assertions that your fixture usages are properly typed.

Problem

Pytest fixtures are magic that mypy does not understand. This typechecks just fine:

@pytest.fixture
def myint():
    return 42

def test_basic(myint: str):
    assert myint == 42

This test passes but the type annotation is wrong.

With this pytest plugin it will pass typechecking all the same, but your test will fail at least.

If your tests do not have type annotations, this plugin does nothing. Use mypy to enforce that everything has type annotations.

Consider vendoring this package by copying its [5 lines of sourcecode](./pytest_fixture_typecheck.py) in your `conftest.py`. The package's metadata is larger than 5 lines.

License

Licensed under public domain.

About

A pytest plugin to assert type annotations at runtime.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages