Improve _open() to avoid mypy and pylint warnings