Skip to content

Skip Py2 subprocess tests if Py2 interpreter found does not have typing installed #4039

Closed
@carljm

Description

@carljm

The behavior of mypy with regard to Python 2.7 tests is inconsistent. On the one hand, if no Python 2.7 interpreter can be found at all, https://github.com/python/mypy/blob/master/mypy/util.py#L66 will return None and mypy will happily skip the Py2 tests. But if a Python 2.7 interpreter is found, but is missing the typing backport (which mypy no longer bundles), mypy will go ahead and run the Py2 tests and they will fail.

Our build boxes are in the midst of an upgrade from an OS version with Python 2.6 as system Python to one with Python 2.7. On the older OS, mypy builds fine and just skips the Py2 tests (which is fine). On the newer OS, it finds the system Python 2.7 and those tests fail for lack of typing. It'sdifficult for us to install the typing module into the system Python on these hosts.

I propose that it would be more consistent if mypy considers "no Python 2.7 with typing available" equivalent to "no Python 2.7 available" and skips the Py2 tests. It would be quite easy to add a python -c "import typing" check to try_find_python2_interpreter. I can submit a PR for this, if the idea is approved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions