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

1.9.0: test_runtime_typing_objects fails #17005

Closed
mtelka opened this issue Mar 9, 2024 · 6 comments
Closed

1.9.0: test_runtime_typing_objects fails #17005

mtelka opened this issue Mar 9, 2024 · 6 comments
Labels
bug mypy got something wrong

Comments

@mtelka
Copy link
Contributor

mtelka commented Mar 9, 2024

Bug Report

I'm running tests for 1.9.0 and I found that the StubtestUnit.test_runtime_typing_objects test fails.

To Reproduce

Run tests.

Expected Behavior

All tests pass.

Actual Behavior

___________________ StubtestUnit.test_runtime_typing_objects ___________________
[gw1] sunos5 -- Python 3.9.18 $(BUILD_DIR)/.tox/py39/bin/python

args = (<mypy.test.teststubtest.StubtestUnit testMethod=test_runtime_typing_objects>,)
kwargs = {}
cases = [<mypy.test.teststubtest.Case object at 0x7fffacfaf550>, <mypy.test.teststubtest.Case object at 0x7fffacfaff10>, <mypy.test.teststubtest.Case object at 0x7fffacfaff40>]
expected_errors = set()
c = <mypy.test.teststubtest.Case object at 0x7fffacfaff40>, @py_assert1 = False
@py_format3 = "{'test_module.Y.__closed__', 'test_module.Y.__extra_items__'} == set()\n~\n~Extra items in the left set:\n~'test_modu...__'\n~\n~Full diff:\n~- set()\n~+ {\n~+     'test_module.Y.__closed__',\n~+     'test_module.Y.__extra_items__',\n~+ }"
@py_format5 = "error: test_module.Y.__closed__ is not present in stub\n~Stub: in file test_module.pyi\n~MISSING\n~Runtime:\n~False\n...__'\n~\n~Full diff:\n~- set()\n~+ {\n~+     'test_module.Y.__closed__',\n~+     'test_module.Y.__extra_items__',\n~+ }"
output = 'error: test_module.Y.__closed__ is not present in stub\nStub: in file test_module.pyi\nMISSING\nRuntime:\nFalse\n\ner... is not present in stub\nStub: in file test_module.pyi\nMISSING\nRuntime:\nNone\n\nFound 2 errors (checked 1 module)\n'
actual_errors = {'test_module.Y.__closed__', 'test_module.Y.__extra_items__'}

    def test(*args: Any, **kwargs: Any) -> None:
        cases = list(fn(*args, **kwargs))
        expected_errors = set()
        for c in cases:
            if c.error is None:
                continue
            expected_error = c.error
            if expected_error == "":
                expected_error = TEST_MODULE_NAME
            elif not expected_error.startswith(f"{TEST_MODULE_NAME}."):
                expected_error = f"{TEST_MODULE_NAME}.{expected_error}"
            assert expected_error not in expected_errors, (
                "collect_cases merges cases into a single stubtest invocation; we already "
                "expect an error for {}".format(expected_error)
            )
            expected_errors.add(expected_error)
        output = run_stubtest(
            stub="\n\n".join(textwrap.dedent(c.stub.lstrip("\n")) for c in cases),
            runtime="\n\n".join(textwrap.dedent(c.runtime.lstrip("\n")) for c in cases),
            options=["--generate-allowlist"],
        )

        actual_errors = set(output.splitlines())
        if actual_errors != expected_errors:
            output = run_stubtest(
                stub="\n\n".join(textwrap.dedent(c.stub.lstrip("\n")) for c in cases),
                runtime="\n\n".join(textwrap.dedent(c.runtime.lstrip("\n")) for c in cases),
                options=[],
            )
>           assert actual_errors == expected_errors, output
E           AssertionError: error: test_module.Y.__closed__ is not present in stub
E             Stub: in file test_module.pyi
E             MISSING
E             Runtime:
E             False
E
E             error: test_module.Y.__extra_items__ is not present in stub
E             Stub: in file test_module.pyi
E             MISSING
E             Runtime:
E             None
E
E             Found 2 errors (checked 1 module)
E
E           assert {'test_module.Y.__closed__', 'test_module.Y.__extra_items__'} == set()
E
E             Extra items in the left set:
E             'test_module.Y.__closed__'
E             'test_module.Y.__extra_items__'
E
E             Full diff:
E             - set()
E             + {
E             +     'test_module.Y.__closed__',
E             +     'test_module.Y.__extra_items__',
E             + }

mypy/test/teststubtest.py:219: AssertionError

Your Environment

  • Mypy version used: 1.9.0
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9.18
@mtelka mtelka added the bug mypy got something wrong label Mar 9, 2024
@JelleZijlstra
Copy link
Member

This probably depends on the version of typing-extensions you have installed.

@mtelka
Copy link
Contributor Author

mtelka commented Mar 9, 2024

I tested with typing-extensions version 4.10.0.

@mr-c
Copy link
Contributor

mr-c commented Mar 11, 2024

Hello, we are also seeing this on Debian. I think typing-extensions 4.10.0 is to blame, because an earlier build I did locally with typing-extensions 4.9.0 didn't have this failure

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1065805

@mr-c
Copy link
Contributor

mr-c commented Mar 11, 2024

Cherry-picking eb84794 into the Debian package fixed the mypy tests for me.

@AlexWaygood
Copy link
Member

I think typing-extensions 4.10.0 is to blame

(arguably the thing that is "to blame" here is the fact that mypy's test fixtures are overly coupled to the exact attributes that typing_extensions.TypedDict has at runtime ;)

@mtelka
Copy link
Contributor Author

mtelka commented Apr 25, 2024

The test is passing with 1.10.0.

@mtelka mtelka closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

4 participants