def yielded_errors( self, request ) -> Tuple[str, ParserTestCase, Tuple[Error]]: # noqa: ANN001 """ Build a fixture for the error codes emitted from parsing the type comments test code. Fixture provides a tuple of: test case name, its corresponding ParserTestCase instance, and a tuple of the errors yielded by the checker """ test_case_name, test_case = request.param return test_case_name, test_case, tuple(check_source(test_case.src))
def parsed_errors( self, request) -> Tuple[List[SIMPLE_ERROR_CODE], str]: # noqa: ANN001 """ Create a fixture for the error codes emitted by the test case source code. Error codes for the test case source code are simplified into a list of (error code, argument name) tuples. """ test_case_name, test_case = request.param simplified_errors = [ _simplify_error(error) for error in check_source(test_case.src) ] return simplified_errors, test_case_name
def yielded_errors( self, request # noqa: ANN001 ) -> Tuple[str, DummyArgSuppressionTestCase, Tuple[FORMATTED_ERROR]]: """ Build a fixture for the error codes emitted from parsing the dummy argument test code. Fixture provides a tuple of: test case name, its corresponding DummyArgSuppressionTestCase instance, and a tuple of the errors yielded by the checker """ test_case_name, test_case = request.param return ( test_case_name, test_case, tuple(check_source(test_case.src, suppress_dummy_args=True)), )
def yielded_errors( self, request # noqa: ANN001 ) -> Tuple[str, NoneReturnSuppressionTestCase, Tuple[Error]]: """ Build a fixture for the error codes emitted from parsing the None return test code. Fixture provides a tuple of: test case name, its corresponding NoneReturnSuppressionTestCase instance, and a tuple of the errors yielded by the checker """ test_case_name, test_case = request.param return ( test_case_name, test_case, tuple(check_source(test_case.src, suppress_none_returns=True)), )
def yielded_errors( self, request # noqa: ANN001 ) -> Tuple[str, MypyInitReturnTestCase, Tuple[FORMATTED_ERROR]]: """ Build a fixture for the error codes emitted from parsing the Mypy __init__ return test code. Fixture provides a tuple of: test case name, its corresponding MypyInitReturnTestCase instance, and a tuple of the errors yielded by the checker """ test_case_name, test_case = request.param return ( test_case_name, test_case, tuple(check_source(test_case.src, mypy_init_return=True)), )
def yielded_errors( self, request # noqa: ANN001 ) -> Tuple[str, TypeCommentArgInjectTestCase, Tuple[FORMATTED_ERROR]]: """ Build a fixture for the error codes emitted from parsing the test code. Fixture provides a tuple of: test case name, its corresponding TypeCommentArgInjectTestCase instance, and a tuple of the errors yielded by the checker. """ test_case_name, test_case = request.param return ( test_case_name, test_case, tuple(check_source(test_case.src)), )
def parsed_errors( request, # noqa: ANN001 ) -> Tuple[Generator[ERROR_CODE, None, None], ParserTestCase]: """ Create a fixture for the error codes emitted by our testing code. `parser_test_cases` is a dictionary of ParserTestCase named tuples, which provide the following: * `src` - Source code for the test case to be parsed * `error_locations` - Truthe value tuple of (row number, column offset) tuples * Row numbers are 1-indexed * Column offsets are 0-indexed when yielded by our checker; flake8 adds 1 when emitted The fixture provides a generator of yielded errors for the input source, along with the test case to use for obtaining truth values """ test_case_name, test_case = request.param return check_source(test_case.src), test_case
def yielded_errors( self, request # noqa: ANN001 ) -> Tuple[str, DynamicallyTypedNestedFunctionTestCase, Tuple[Error]]: """ Build a fixture for the errors emitted from parsing the dynamically typed def test code. Fixture provides a tuple of: test case name, its corresponding `DynamicallyTypedNestedFunctionTestCase` instance, and a tuple of the errors yielded by the checker, which should be empty if the test case's `should_yield_error` is `False`. """ test_case_name, test_case = request.param return ( test_case_name, test_case, tuple(check_source(test_case.src, allow_untyped_nested=True)), )
def yielded_errors( self, request # noqa: ANN001 ) -> Tuple[str, DispatchDecoratorTestCase, Tuple[Error]]: """ Build a fixture for the errors emitted from parsing dispatch decorated test code. Fixture provides a tuple of: test case name, its corresponding `DispatchDecoratorTestCase` instance, and a tuple of the errors yielded by the checker, which should be empty if the test case's `should_yield_error` is `False`. To support decorator aliases, the `dispatch_decorators` param is optionally specified by the test case. If none is explicitly set, the decorator list defaults to the checker's default. """ test_case_name, test_case = request.param return ( test_case_name, test_case, tuple(check_source(test_case.src, dispatch_decorators=test_case.dispatch_decorators)), )
def test_dynamic_typing_errors(src: str) -> None: found_errors = list(check_source(src)) assert len(found_errors) == 1 _, _, err_msg, _ = found_errors[0] assert "ANN401" in err_msg
def test_ignore_stargs(src: str) -> None: found_errors = list(check_source(src, allow_star_arg_any=True)) assert len(found_errors) == 0