From 86bcf3387f0e5ff1c518928d296928e8b66a8412 Mon Sep 17 00:00:00 2001 From: Kier Davis Date: Sat, 30 Mar 2019 18:16:50 +0000 Subject: [PATCH] Add type stub for pytest The only part of the API we reference directly from the code in `tests/` is the bare minimum `pytest.raises`, so that's all I've implemented here. Apparently pytest are working on providing type stubs, but it's not at a usable state yet: https://github.com/pytest-dev/pytest/issues/3342 --- stubs/pytest.pyi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 stubs/pytest.pyi diff --git a/stubs/pytest.pyi b/stubs/pytest.pyi new file mode 100644 index 00000000..d5fec82c --- /dev/null +++ b/stubs/pytest.pyi @@ -0,0 +1,15 @@ +""" +Type stubs for pytest. + +Note that stubs are only written for the parts that we use. +""" + +from typing import ContextManager, Type + + +# This function actually has more arguments than are specified here, and the +# context manager actually yields a _pytest._code.ExceptionInfo instead of None. +# We don't use either of these features, so I don't think its worth including +# them in our type stub. We can always change it later. +def raises(exc_type: Type[Exception]) -> ContextManager[None]: + ...