Title: Regression from 0.750 - Literal types cause significant slowdown · Issue #9169 · python/mypy · GitHub
Open Graph Title: Regression from 0.750 - Literal types cause significant slowdown · Issue #9169 · python/mypy
X Title: Regression from 0.750 - Literal types cause significant slowdown · Issue #9169 · python/mypy
Description: Are you reporting a bug, or opening a feature request? This is a bug. It is a regression from the 0.750 version. Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if...
Open Graph Description: Are you reporting a bug, or opening a feature request? This is a bug. It is a regression from the 0.750 version. Please insert below the code you are checking with mypy, or a mock-up repro if the s...
X Description: Are you reporting a bug, or opening a feature request? This is a bug. It is a regression from the 0.750 version. Please insert below the code you are checking with mypy, or a mock-up repro if the s...
Opengraph URL: https://github.com/python/mypy/issues/9169
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression from 0.750 - Literal types cause significant slowdown","articleBody":"### Are you reporting a bug, or opening a feature request?\r\n\r\nThis is a bug. It is a regression from the 0.750 version.\r\n\r\n### Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to simplify your case to a minimal repro.\r\n\r\nHere is the code that triggers this bug. It is essentially a list of `TypedDict` objects created in some nested fashion. The definitions for these objects are coming from the `boto3-stubs` library, which is a typed wrapper around the `boto3` library, which is a Python SDK for talking to AWS REST APIs. The same behavior could probably be reproduced with just custom made `TypeDict` objects, but, given, the number of them and the relationship between them, it is easier just to reuse the ones from the library.\r\n\r\nTo install it, you need to have this line in `requirements.txt` (the exact version probably does not matter, but this is what I have):\r\n\r\n```\r\nboto3-stubs[autoscaling,cloudwatch,ec2,lambda,logs] == 1.10.35\r\n```\r\n\r\n**IMPORTANT:** After running `pip install` for the above line, one must also run this command to make `boto3-stubs` initialize itself:\r\n\r\n```\r\npython -m mypy_boto3\r\n```\r\n\r\nIf doing this from `tox.ini`, you need to have this line there:\r\n\r\n```\r\ncommands_pre = python -m mypy_boto3\r\n```\r\n\r\nHere is the offending code:\r\n\r\n```\r\nimport typing as t\r\n\r\nfrom mypy_boto3.ec2.type_defs import (\r\n DescribeInstancesResultTypeDef,\r\n FilterTypeDef,\r\n InstanceNetworkInterfaceAttachmentTypeDef,\r\n InstanceNetworkInterfaceTypeDef,\r\n InstanceStateTypeDef,\r\n InstanceTypeDef,\r\n PlacementTypeDef,\r\n ReservationTypeDef,\r\n TagTypeDef,\r\n)\r\n\r\nx: t.List[DescribeInstancesResultTypeDef] = [\r\n DescribeInstancesResultTypeDef(\r\n Reservations=[\r\n ReservationTypeDef(\r\n Instances=[\r\n InstanceTypeDef(\r\n InstanceId=\"az1-instance1-id1\",\r\n Placement=PlacementTypeDef(\r\n AvailabilityZone=\"az1\",\r\n ),\r\n State=InstanceStateTypeDef(\r\n Name=\"running\",\r\n ),\r\n NetworkInterfaces=[\r\n InstanceNetworkInterfaceTypeDef(\r\n Attachment=InstanceNetworkInterfaceAttachmentTypeDef(\r\n DeviceIndex=0,\r\n ),\r\n NetworkInterfaceId=\"az1-instance1-nic0-id1\",\r\n PrivateDnsName=\"az1-instance1-nic0-dns1\",\r\n PrivateIpAddress=\"az1-instance1-nic0-ip1\",\r\n SourceDestCheck=True,\r\n ),\r\n ],\r\n Tags=[\r\n TagTypeDef(\r\n Key=\"Name\",\r\n Value=\"az1-instance1\",\r\n ),\r\n ],\r\n ),\r\n ],\r\n ),\r\n ],\r\n NextToken=\"next-token1\",\r\n ),\r\n DescribeInstancesResultTypeDef(\r\n Reservations=[\r\n ReservationTypeDef(\r\n Instances=[\r\n InstanceTypeDef(\r\n InstanceId=\"az1-instance2-id2\",\r\n Placement=PlacementTypeDef(\r\n AvailabilityZone=\"az1\",\r\n ),\r\n State=InstanceStateTypeDef(\r\n Name=\"running\",\r\n ),\r\n NetworkInterfaces=[\r\n InstanceNetworkInterfaceTypeDef(\r\n Attachment=InstanceNetworkInterfaceAttachmentTypeDef(\r\n DeviceIndex=0,\r\n ),\r\n NetworkInterfaceId=\"az1-instance2-nic0-id2\",\r\n PrivateDnsName=\"az1-instance2-nic0-dns2\",\r\n PrivateIpAddress=\"az1-instance2-nic0-ip2\",\r\n SourceDestCheck=True,\r\n ),\r\n ],\r\n Tags=[\r\n TagTypeDef(\r\n Key=\"Name\",\r\n Value=\"az1-instance2\",\r\n ),\r\n ],\r\n ),\r\n ],\r\n ),\r\n ],\r\n NextToken=\"next-token2\",\r\n ),\r\n DescribeInstancesResultTypeDef(\r\n Reservations=[\r\n ReservationTypeDef(\r\n Instances=[\r\n InstanceTypeDef(\r\n InstanceId=\"az2-instance1-id1\",\r\n Placement=PlacementTypeDef(\r\n AvailabilityZone=\"az2\",\r\n ),\r\n State=InstanceStateTypeDef(\r\n Name=\"running\",\r\n ),\r\n NetworkInterfaces=[\r\n InstanceNetworkInterfaceTypeDef(\r\n Attachment=InstanceNetworkInterfaceAttachmentTypeDef(\r\n DeviceIndex=0,\r\n ),\r\n NetworkInterfaceId=\"az2-instance1-nic0-id1\",\r\n PrivateDnsName=\"az2-instance1-nic0-dns1\",\r\n PrivateIpAddress=\"az2-instance1-nic0-ip1\",\r\n SourceDestCheck=True,\r\n ),\r\n ],\r\n Tags=[\r\n TagTypeDef(\r\n Key=\"Name\",\r\n Value=\"az2-instance1\",\r\n ),\r\n ],\r\n ),\r\n ],\r\n ),\r\n ],\r\n ),\r\n]\r\n```\r\n\r\n### What is the actual behavior/output?\r\n\r\nWhen running `mypy` for this file, version 0.750 takes about 8-10 seconds to complete without any errors (with a brand new completely empty `.mypy_cache`). All versions after that (for the list of versions I tried, see below) essentially hang and never complete. When I was doing this on the actual project code, I had `mypy` running for at least half an hour. When running experiments specifically with the above code, I waited for a couple of minutes for each version before killing it in the Task Manager.\r\n\r\n### What is the behavior/output you expect?\r\n\r\n`mypy` should not hang on this file.\r\n\r\n### What are the versions of mypy and Python you are using?\r\n\r\n```\r\n> python --version --version\r\nPython 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]\r\n```\r\n\r\n`mypy` versions tried:\r\n\r\n* 0.750 - works\r\n* 0.761 - hangs\r\n* 0.770 - hangs\r\n* 0.780 - hangs\r\n* 0.782 - hangs\r\n\r\n### Do you see the same issue after installing mypy from Git master?\r\n\r\nI only tried the officially published versions listed above.\r\n\r\n### What are the mypy flags you are using? (For example --strict-optional)\r\n\r\nHere is the content of `mypy.ini` that I used:\r\n\r\n```\r\n[mypy]\r\nmypy_path = ./stubs\r\n\r\n# How imports are handled\r\nignore_missing_imports = False\r\nfollow_imports = normal\r\n\r\n# Enforce various type annotations\r\ndisallow_any_unimported = True\r\ndisallow_any_expr = False\r\ndisallow_any_decorated = False\r\ndisallow_any_explicit = False\r\ndisallow_any_generics = True\r\ndisallow_subclassing_any = True\r\ndisallow_untyped_calls = True\r\ndisallow_untyped_defs = True\r\ndisallow_incomplete_defs = True\r\ndisallow_untyped_decorators = True\r\n\r\n# Various code quality checks\r\nno_implicit_optional = True\r\nstrict_optional = True\r\nwarn_unused_ignores = True\r\nwarn_no_return = True\r\nwarn_return_any = True\r\nwarn_unreachable = True\r\nwarn_redundant_casts = True\r\nallow_untyped_globals = False\r\nallow_redefinition = False\r\nstrict_equality = True\r\n\r\n# How error messages are printed\r\nshow_error_context = False\r\nshow_column_numbers = True\r\nshow_error_codes = True\r\npretty = True\r\n```\r\n\r\n### If mypy crashed with a traceback, please paste the full traceback below.\r\n\r\n`mypy` does not crash, just hangs. It needs to be killed in the Task Manager to stop it. It does not even respond to `Ctrl`+`C`.\r\n\r\n","author":{"url":"https://github.com/CommanderPrS","@type":"Person","name":"CommanderPrS"},"datePublished":"2020-07-18T05:50:43Z","url":"https://github.com/python/mypy/issues/9169"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7461442d-3f7e-6d05-f768-6ed1a8cf3736 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F9A:30E5B0:309117E:402C8FF:6B002A9D |
| html-safe-nonce | 693bec122d53fa58e6fb7af98bf0a47f03763c167ab47853d50dbe6ad809ae96 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjlBOjMwRTVCMDozMDkxMTdFOjQwMkM4RkY6NkIwMDJBOUQiLCJ2aXNpdG9yX2lkIjoiNjcwMTYwMjU2Nzk5MTg2Mzk2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a41de7346b7ec1223f28eff5fdedb25d660b001357b8e1fc3447a395c49696f9 |
| hovercard-subject-tag | issue:659929668 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/9169/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da5da08d40e0911a599622ce8066e7ff9fdcd462485c809a5c95a80b574c6e0a/python/mypy/issues/9169 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da5da08d40e0911a599622ce8066e7ff9fdcd462485c809a5c95a80b574c6e0a/python/mypy/issues/9169 |
| og:image:alt | Are you reporting a bug, or opening a feature request? This is a bug. It is a regression from the 0.750 version. Please insert below the code you are checking with mypy, or a mock-up repro if the s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | CommanderPrS |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width