Read and rewrite *fn* and return the code object.
(fn: Path, config: Config)
| 341 | |
| 342 | |
| 343 | def _rewrite_test(fn: Path, config: Config) -> tuple[os.stat_result, types.CodeType]: |
| 344 | """Read and rewrite *fn* and return the code object.""" |
| 345 | stat = os.stat(fn) |
| 346 | source = fn.read_bytes() |
| 347 | strfn = str(fn) |
| 348 | tree = ast.parse(source, filename=strfn) |
| 349 | rewrite_asserts(tree, source, strfn, config) |
| 350 | co = compile(tree, strfn, "exec", dont_inherit=True) |
| 351 | return stat, co |
| 352 | |
| 353 | |
| 354 | def _read_pyc( |