During the port to Python 3, we sometimes need to modify the Python 2 standard library so that it looks like the version found on Python 3. We do this using install_aliases
:
from future import standard_library
standard_library.install_aliases()
I had not realized this until the weekend, but it is in retrospect obvious that this changes the global state of Python when importing packages. I have modified the base
package to do this import so that all code that uses standard LSST importing will have the aliased imports available on Python 2 (it’s a no-op on Python 3).
The result is that you no longer need to add this to each module. There is at least one case where code was expecting this to already be true but was working because pex_exceptions
was installing the aliases (it no longer does). You may still have to use it in scripts that need to import aliased modules before any LSST importing is done.
This has the advantage that it is easier to make our code pass flake8
linting because we are no longer running code before imports happen.