Skip to content

1.9.0: test_runtime_typing_objects fails #17005

Closed

Description

@mtelka

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

Activity

  1. JelleZijlstra commented on Mar 9, 2024

    @JelleZijlstra
    Member

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

  2. mtelka commented on Mar 9, 2024

    @mtelka
    ContributorAuthor

    I tested with typing-extensions version 4.10.0.

  3. mr-c commented on Mar 11, 2024

    @mr-c
    Contributor

    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

  4. mr-c commented on Mar 11, 2024

    @mr-c
    Contributor

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

  5. AlexWaygood commented on Mar 11, 2024

    @AlexWaygood
    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 ;)

  6. mtelka commented on Apr 25, 2024

    @mtelka
    ContributorAuthor

    The test is passing with 1.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions