On Sat, Jan 22, 2022 at 4:54 PM Jelle Zijlstra
El sáb, 22 ene 2022 a las 16:51, Martin DeMello (
) escribió: Is the ultimate goal to let inline tests be written as part of a type stub? Or are you just looking for a lighter weight way to write a separate test suite?
I don't think these functions should be used in stubs directly. I anticipate that typeshed would have a separate tests directory full of `assert_type()` and `assert_error()`, with CI that runs each supported type checker on the tests.
The scheme we use for pytype's unit tests is worth considering, then - types asserted via assert_type, but errors asserted with comments. So e.g. x = 1 assert_type(x, int) x.strip() # attribute-error[e] The [e] after the error code is optional, but if supplied the full text of the error will be captured as errors["e"], so that assertions can be run on it. We currently express the test snippets themselves as strings in the code, but if people like the general idea I would be happy to work up a proposal for some sort of structured format to have several tests in a single file, and for some form of error assertion that is not tied to pytype's specific error codes. martin