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

Fix regression when a contextmanager yields a generic #11870

Merged
merged 1 commit into from
Jan 5, 2022
Merged

Fix regression when a contextmanager yields a generic #11870

merged 1 commit into from
Jan 5, 2022

Conversation

asottile
Copy link
Contributor

Description

resolves #11852

I had to back out some of the tests added in the patch which regressed this behaviour -- once I had "fixed" them they were identical to existing tests

I added a new test to cover the behaviour that had regressed. I had to simplify it a bit from the one in the issue due to missing fixtures

Test Plan

automated tests in the patch itself -- the added test fails on master:

___________________ testContextManagerReturnsGenericFunction ___________________
[gw2] linux -- Python 3.7.12 /tmp/mypy/.tox/py37/bin/python
data: /tmp/mypy/test-data/unit/check-default-plugin.test:45:
../mypy/mypy/test/testcheck.py:140: in run_case
    self.run_case_once(testcase)
../mypy/mypy/test/testcheck.py:227: in run_case_once
    assert_string_arrays_equal(output, a, msg.format(testcase.file, testcase.line))
E   AssertionError: Unexpected type checker output (/tmp/mypy/test-data/unit/check-default-plugin.test, line 45)
----------------------------- Captured stderr call -----------------------------
Expected:
  main:26: note: Revealed type is "builtins.list[builtins.int*]" (diff)
Actual:
  main:24: error: Need type annotation for "m"  (diff)
  main:26: note: Revealed type is "builtins.list[Any]" (diff)

Alignment of first line difference:
  E: main:26: note: Revealed type is "builtins.list[builtins.int*]"
  A: main:24: error: Need type annotation for "m"
           ^

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Looks good.

@JukkaL JukkaL merged commit 06afa7c into python:master Jan 5, 2022
@asottile asottile deleted the fix-generator-contextmanager-generics branch January 5, 2022 16:47
JukkaL pushed a commit that referenced this pull request Jan 5, 2022
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mypy 0.930: regression: no longer keeping contextmanager generic return value
2 participants