Skip to content

Python 2 future import can leak between modules #11740

Closed
@JukkaL

Description

@JukkaL

This test case fails unexpectedly:

[case testDivPython2FutureImportNotLeaking]
# flags: --python-version 2.7
import m1

[file m1.py]
import m2

class A(object):
    def __div__(self, other):
        # type: (str) -> str
        return 'a'

reveal_type(A() / 'b')  # N: Revealed type is "builtins.str"

[file m2.py]
from __future__ import division
[builtins fixtures/bool.pyi]

If I comment out the from __future__ import, the test case passes. It looks like the __future__ import leaks from m2 to m1. This was introduced in #11276.

Since we are close to creating a release brach, and the fix may be non-trivial, I'm going to revert #11276 to avoid a regression. The PR can be merged again once the issue has been fixed.

cc @sobolevn

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions