Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2 future import can leak between modules #11740

Closed
JukkaL opened this issue Dec 14, 2021 · 1 comment · Fixed by #11787
Closed

Python 2 future import can leak between modules #11740

JukkaL opened this issue Dec 14, 2021 · 1 comment · Fixed by #11787
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 14, 2021

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

@JukkaL JukkaL added bug mypy got something wrong false-positive mypy gave an error on correct code labels Dec 14, 2021
JukkaL added a commit that referenced this issue Dec 14, 2021
This reverts commit e6b91bd.

See #11740 for the context.
@sobolevn
Copy link
Member

Ok, I will take a look why future imports leak and re-create this PR with your test. Thanks!

JukkaL added a commit that referenced this issue Dec 14, 2021
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this issue Jan 20, 2022
JukkaL pushed a commit that referenced this issue Feb 23, 2022
…11787)

Now `__future__` imports do not leak in semanal.py.

Closes #11740
Refs #11741
Refs #11276
Refs #11700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants