Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an upcoming pytype error in absltest.
I'm working on an improvement to pytype's type-checking of function type comments, which exposes an annotation error in absltest. _TempFile._open() was annotated as returning Union[TextIO, BinaryIO] but is used as: def open_text(...) -> ContextManager[TextIO]: ... return self._open(...) which will cause pytype to complain about open_text returning bytes when text is expected. The proper way to fix this issue would be to use typing.overload and typing.Literal to define multiple signatures for _open(), but pytype doesn't fully support Literal yet, so I've added type comments with the right types in open_text() and open_bytes(). This change also fixes a mistake in the return annotation on _open() and alphabetically orders all typing imports. PiperOrigin-RevId: 283783117 Change-Id: I4d78a9eb1c98218e62a9b0662931213f7c5c1668
- Loading branch information