def get_mypychecker(self, file: Union[Path, str]) -> MypyChecker: current = Path('.').absolute() filename = Path(__file__).relative_to(current).parent / file with filename.open('r', encoding='utf8', errors='surrogateescape') as f: lines = f.readlines() options = mock.MagicMock() options.mypy_config = None return MypyChecker( filename=str(filename), lines=lines, tree=ast.parse(''.join(lines)), options=options, )
def errors(self, *errors: Error) -> List[_Flake8Error]: return [MypyChecker.adapt_error(e) for e in errors]