Title: Unexpectedly encountered partial type · Issue #16573 · python/mypy · GitHub
Open Graph Title: Unexpectedly encountered partial type · Issue #16573 · python/mypy
X Title: Unexpectedly encountered partial type · Issue #16573 · python/mypy
Description: Bug Report With updating from mypy 1.6.1 -> 1.7.1 I get an assertion error: "AssertionError: Unexpectedly encountered partial type". This happens in the released version 1.7.1 as well as on the current git main branch. To Reproduce from ...
Open Graph Description: Bug Report With updating from mypy 1.6.1 -> 1.7.1 I get an assertion error: "AssertionError: Unexpectedly encountered partial type". This happens in the released version 1.7.1 as well as on the cur...
X Description: Bug Report With updating from mypy 1.6.1 -> 1.7.1 I get an assertion error: "AssertionError: Unexpectedly encountered partial type". This happens in the released version 1.7.1 as well ...
Opengraph URL: https://github.com/python/mypy/issues/16573
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpectedly encountered partial type","articleBody":"**Bug Report**\r\n\r\nWith updating from mypy `1.6.1` -> `1.7.1` I get an assertion error: \"AssertionError: Unexpectedly encountered partial type\". This happens in the released version `1.7.1` as well as on the current git main branch.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import Any\r\n\r\nfrom pymongo import MongoClient\r\nfrom pymongo.errors import ConnectionFailure\r\nfrom celery import Celery\r\nfrom celery.signals import worker_process_init, worker_process_shutdown\r\n\r\n\r\ncelery_app = Celery(__name__)\r\ncelery_app.conf.broker_url = \"\"\r\ncelery_app.conf.result_backend = \"\"\r\n\r\n# MongoDB setup\r\nclient = None\r\ndb = None\r\ncollection = None\r\n\r\n\r\n@worker_process_init.connect\r\ndef init_worker(**_kwargs: Any) -> None:\r\n \"\"\"\r\n Will be run on initialization of each worker. When you run 12 workers, you will need to have\r\n 12 database connections. Here you can get them.\r\n \"\"\"\r\n global client, db, collection\r\n if client := MongoClient(\"\"):\r\n db = getattr(client, \"\")\r\n collection = db[\"\"]\r\n else:\r\n raise ConnectionFailure(\r\n \"Cannot connect to database. Please check your config and network settings.\"\r\n )\r\n\r\n\r\n@worker_process_shutdown.connect\r\ndef shutdown_worker(**_kwargs: Any) -> None:\r\n \"\"\"\r\n Shutdown everything at the end of a worker’s lifetime, e.g. database connections\r\n \"\"\"\r\n if client:\r\n client.close()\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nMypy should not raise an assertion.\r\n\r\n**Actual Behavior**\r\n\r\nThis is the output from current mypy version from git:\r\n\r\n```\r\nmypy --show-traceback my_project \r\nmy_project/worker.py:45: error: INTERNAL ERROR -- Please try using mypy master on GitHub:\r\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 1.8.0+dev.e69c5cde8643e04a54a644cc27814ab98181541d\r\nTraceback (most recent call last):\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/bin/mypy\", line 8, in \u003cmodule>\r\n sys.exit(console_entry())\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/__main__.py\", line 15, in console_entry\r\n main()\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/main.py\", line 100, in main\r\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/main.py\", line 182, in run_build\r\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/build.py\", line 191, in build\r\n result = _build(\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/build.py\", line 265, in _build\r\n graph = dispatch(sources, manager, stdout)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/build.py\", line 2943, in dispatch\r\n process_graph(graph, manager)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/build.py\", line 3341, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/build.py\", line 3442, in process_stale_scc\r\n graph[id].type_check_first_pass()\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/build.py\", line 2311, in type_check_first_pass\r\n self.type_checker().check_first_pass()\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 481, in check_first_pass\r\n self.accept(d)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 591, in accept\r\n stmt.accept(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/nodes.py\", line 897, in accept\r\n return visitor.visit_decorator(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 4884, in visit_decorator\r\n self.visit_decorator_inner(e)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 4889, in visit_decorator_inner\r\n self.check_func_item(e.func, name=e.func.name, allow_empty=allow_empty)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 1077, in check_func_item\r\n self.check_func_def(defn, typ, name, allow_empty)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 1293, in check_func_def\r\n self.accept(item.body)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 591, in accept\r\n stmt.accept(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/nodes.py\", line 1223, in accept\r\n return visitor.visit_block(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 2770, in visit_block\r\n self.accept(s)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 591, in accept\r\n stmt.accept(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/nodes.py\", line 1491, in accept\r\n return visitor.visit_if_stmt(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 4525, in visit_if_stmt\r\n self.accept(b)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 591, in accept\r\n stmt.accept(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/nodes.py\", line 1223, in accept\r\n return visitor.visit_block(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 2770, in visit_block\r\n self.accept(s)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 591, in accept\r\n stmt.accept(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/nodes.py\", line 1310, in accept\r\n return visitor.visit_assignment_stmt(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 2818, in visit_assignment_stmt\r\n self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checker.py\", line 2922, in check_assignment\r\n rvalue_type = self.expr_checker.accept(rvalue)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 5727, in accept\r\n typ = node.accept(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/nodes.py\", line 1904, in accept\r\n return visitor.visit_call_expr(self)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 473, in visit_call_expr\r\n return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 602, in visit_call_expr_inner\r\n ret_type = self.check_call_expr_with_callee_type(\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 1440, in check_call_expr_with_callee_type\r\n ret_type, callee_type = self.check_call(\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 1546, in check_call\r\n return self.check_overload_call(\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 2606, in check_overload_call\r\n arg_types = self.infer_arg_types_in_empty_context(args)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 1868, in infer_arg_types_in_empty_context\r\n arg_type = self.accept(arg)\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 5727, in accept\r\n typ = node.accept(self)\r\n ^^^^^^^^^^^^^^^^^\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/nodes.py\", line 1806, in accept\r\n return visitor.visit_name_expr(self)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 358, in visit_name_expr\r\n return self.narrow_type_from_binder(e, result)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/checkexpr.py\", line 6062, in narrow_type_from_binder\r\n return narrow_declared_type(known_type, restriction)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/meet.py\", line 144, in narrow_declared_type\r\n elif not is_overlapping_types(declared, narrowed, prohibit_none_typevar_overlap=True):\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/user/.cache/pypoetry/virtualenvs/my-project-34kD4rpW-py3.11/lib/python3.11/site-packages/mypy/meet.py\", line 304, in is_overlapping_types\r\n assert False, \"Unexpectedly encountered partial type\"\r\nAssertionError: Unexpectedly encountered partial type\r\nmy_project/worker.py:45: : note: use --pdb to drop into pdb\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.7.1\r\n- Mypy command-line flags: none\r\n- Mypy configuration options from `mypy.ini` (and other config files):\r\n\r\n```toml\r\n[tool.mypy]\r\npython_version = \"3.11\"\r\nplugins = \"pydantic.mypy\"\r\nfollow_imports = \"silent\"\r\nwarn_redundant_casts = true\r\nwarn_unused_ignores = true\r\ncheck_untyped_defs = true\r\ndisallow_untyped_defs = true\r\n\r\n[tool.pydantic-mypy]\r\ninit_forbid_extra = true\r\ninit_typed = true\r\nwarn_required_dynamic_aliases = true\r\nwarn_untyped_fields = true\r\n\r\n[[tool.mypy.overrides]]\r\nmodule = \"xxx.*\"\r\nignore_missing_imports = true\r\n``` \r\n\r\n- Python version used: 3.11.6\r\n","author":{"url":"https://github.com/sr-verde","@type":"Person","name":"sr-verde"},"datePublished":"2023-11-27T08:14:55Z","url":"https://github.com/python/mypy/issues/16573"}
| 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:27cca268-c6aa-370d-dcc0-1f57ad91a014 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E638:37BEAD:284F991:370EE7F:6B0049B9 |
| html-safe-nonce | 811ce019362c5121e6ac31c35a924d9ca341077bffa6d29ae7c82eb3a29658bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjM4OjM3QkVBRDoyODRGOTkxOjM3MEVFN0Y6NkIwMDQ5QjkiLCJ2aXNpdG9yX2lkIjoiMjI5MzMzNDUyMDA1NDY5NjM3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b59c7145bf386d6b00df7fbd1511071e5640eb306bdb9f8297313bbcb9a31c90 |
| hovercard-subject-tag | issue:2011734777 |
| 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/16573/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d7b08942473e9b266c35288ff6ab9e401350902eea2856846d6dbac2d4a60478/python/mypy/issues/16573 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d7b08942473e9b266c35288ff6ab9e401350902eea2856846d6dbac2d4a60478/python/mypy/issues/16573 |
| og:image:alt | Bug Report With updating from mypy 1.6.1 -> 1.7.1 I get an assertion error: "AssertionError: Unexpectedly encountered partial type". This happens in the released version 1.7.1 as well as on the cur... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sr-verde |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| 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 | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width