Title: AssertionError: Cannot find component 'SSL' for 'OpenSSL.SSL.Context depdendt on SCCs ordering in incremental checks · Issue #20655 · python/mypy · GitHub
Open Graph Title: AssertionError: Cannot find component 'SSL' for 'OpenSSL.SSL.Context depdendt on SCCs ordering in incremental checks · Issue #20655 · python/mypy
X Title: AssertionError: Cannot find component 'SSL' for 'OpenSSL.SSL.Context depdendt on SCCs ordering in incremental checks · Issue #20655 · python/mypy
Description: Crash Report I'm running mypy through the Pants build system on an internal Python monorepo. You can think of Pants as roughly in the vein of Bazel, or Buck2 if you are more familiar with those systems. Notably Pants runs typechecking (a...
Open Graph Description: Crash Report I'm running mypy through the Pants build system on an internal Python monorepo. You can think of Pants as roughly in the vein of Bazel, or Buck2 if you are more familiar with those sys...
X Description: Crash Report I'm running mypy through the Pants build system on an internal Python monorepo. You can think of Pants as roughly in the vein of Bazel, or Buck2 if you are more familiar with those...
Opengraph URL: https://github.com/python/mypy/issues/20655
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AssertionError: Cannot find component 'SSL' for 'OpenSSL.SSL.Context depdendt on SCCs ordering in incremental checks","articleBody":"**Crash Report**\n\nI'm running mypy through the [Pants build system](https://www.pantsbuild.org/) on an internal Python monorepo. You can think of Pants as roughly in the vein of Bazel, or Buck2 if you are more familiar with those systems. Notably Pants runs typechecking (along with most other operations) in an ephemeral sandbox with the minimum dependency set needed. So if I have `src/{foo,bar,bax}` and I check `src/foo` only the transitive dependencies of `src/foo` are included (and not `bar` or `bax`). While it is common to typecheck the whole monorepo, it is also common to just check the little library in the corner you are working on, or dynamically check what has changed since trunk. This means that the packages that mypy can see in the environment can vary significantly on each run. This is historically a source of anecdotal reports of \"spooky\" issues with the mypy cache \u003chttps://github.com/pantsbuild/pants/issues/18519> -- some of wich have been fixed; thank you!\n\n(An alternative design would be to use a separate cache per target combination, but that would produce poor hit rates and an explosion of storage).\n\nThis issue attempts to describe one such issue that leads to an `AssertionError` when type checking code that uses `pyopenssl`. I think this is *likely* the same issue as #19477. I've attempted fixes that suggest overlap with #16214, but I think that is related as opposed to identical.\n\n\n**Traceback**\n\n```python-traceback\nTraceback (most recent call last):\n File \"/workspace/build/CI/MY_REPO/pants.d.cache/pex_root/venvs/3/00d861817b8c511dac47c6904fb3ad1319d7fd53/a94ba71a28dab5f2849156666f783a089f13d400/pex\", line 380, in \u003cmodule>\n boot(\n File \"/workspace/build/CI/MY_REPO/pants.d.cache/pex_root/venvs/3/00d861817b8c511dac47c6904fb3ad1319d7fd53/a94ba71a28dab5f2849156666f783a089f13d400/pex\", line 368, in boot\n sys.exit(func())\n ^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/__main__.py\", line 15, in console_entry\n main()\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/main.py\", line 135, in main\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/main.py\", line 219, in run_build\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 351, in build\n result = build_inner(\n ^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 448, in build_inner\n graph = dispatch(sources, manager, stdout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 3214, in dispatch\n process_graph(graph, manager)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 3625, in process_graph\n done, still_working, results = manager.wait_for_done(graph)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 1101, in wait_for_done\n process_stale_scc(graph, next_scc, self)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 3755, in process_stale_scc\n process_fresh_modules(graph, sorted(prev_scc.mod_ids), manager)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 3703, in process_fresh_modules\n graph[id].fix_cross_refs()\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/build.py\", line 2364, in fix_cross_refs\n fixup_module(self.tree, self.manager.modules, self.options.use_fine_grained_cache)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 53, in fixup_module\n node_fixer.visit_symbol_table(tree.names, tree.fullname)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 160, in visit_symbol_table\n self.visit_type_info(value.node)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 73, in visit_type_info\n self.visit_symbol_table(info.names, info.fullname)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 162, in visit_symbol_table\n value.node.accept(self)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/nodes.py\", line 1164, in accept\n return visitor.visit_decorator(self)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 192, in visit_decorator\n d.func.accept(self)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/nodes.py\", line 1004, in accept\n return visitor.visit_func_def(self)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 170, in visit_func_def\n func.type.accept(self.type_fixer)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/types.py\", line 2337, in accept\n return visitor.visit_callable_type(self)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 281, in visit_callable_type\n argt.accept(self)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/types.py\", line 3394, in accept\n return visitor.visit_union_type(self)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 374, in visit_union_type\n it.accept(self)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/types.py\", line 1686, in accept\n return visitor.visit_instance(self)\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 245, in visit_instance\n inst.type = lookup_fully_qualified_typeinfo(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/fixup.py\", line 383, in lookup_fully_qualified_typeinfo\n stnode = lookup_fully_qualified(name, modules, raise_on_missing=not allow_missing)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/workspace/build/CI/MY_REPO/.cache/pants/named_caches/pex_root/venvs/3/s/77d10232/venv/lib/python3.12/site-packages/mypy/lookup.py\", line 53, in lookup_fully_qualified\n assert key in names, f\"Cannot find component {key!r} for {name!r}\"\n ^^^^^^^^^^^^\nAssertionError: Cannot find component 'SSL' for 'OpenSSL.SSL.Context'\n```\n\n**To Reproduce**\n\nAlas! I have been unable so far to create a deterministic self contained reproduction. I'm going to instead give a qualitative explanation that I hope explains what is going on from post-hoc cache inspection, trace logs, and smashing LLMs against them. In my monorepo I've rigged a setup to generate each [combination](https://docs.python.org/3/library/itertools.html#itertools.combinations) of available targets (so `src/*`, `src/foo`, `src/bar`, `src/foo & src/bar`, etc in my example above). I then run this in N shards and see what pops up. This deterministically produces the error (shard 107 is always one of the ones that hits it), but not in a way I've been able to isolate and extract stand alone. I've then downloaded the trace logs and caches for local analysis.\n\n\nThe trace that doesn't hit this error looks something like:\n\n```\nLine 14669: TRACE: Found fresh SCC (OpenSSL)\nLine 14711: TRACE: Found fresh SCC (OpenSSL.crypto)\nLine 14751: TRACE: Found fresh SCC (OpenSSL.SSL)\n...\nLine 18530: LOG: Processing 131 fresh SCCs\nLine 18563: TRACE: Load tree OpenSSL\nLine 18682: TRACE: Load tree OpenSSL.crypto\nLine 18685: TRACE: Load tree OpenSSL.SSL ← All three loaded in same batch\n```\n\nWhile an error trace is along the lines of:\n```\nLine 14305: TRACE: Found fresh SCC (OpenSSL)\nLine 15297: TRACE: Found fresh SCC (OpenSSL.crypto)\nLine 15340: TRACE: Found fresh SCC (OpenSSL.SSL)\n...\nLine 16649: LOG: Processing 63 fresh SCCs\nLine 16668: TRACE: Load tree OpenSSL ← Only parent loaded\nLine 16764: TRACE: Load tree redis.client ← Has OpenSSL.SSL.Context type ref\nLine 16870: AssertionError ← fix_cross_refs fails\n```\n\nLLM \"Why OpenSSL.SSL Wasn't Loaded\" ascii art\n\n\n```\nThe dependency chain is:\n\nmy_src.mcp_server.prompts (NEW, no cache)\n └── imports → my_src.mcp_server.config (interface changed)\n └── imports → my_src.mcp_server.metrics (stale)\n └── imports → ... → redis.client (fresh, from cache)\n └── imports → OpenSSL (parent package)\n └── type_ref → \"OpenSSL.SSL.Context\" (NOT an import!)\n\nSince `redis.client` only **imports** `OpenSSL` (the parent), not `OpenSSL.SSL`, the SCC dependency graph doesn't include `OpenSSL.SSL`. The type reference `\"OpenSSL.SSL.Context\"` is stored as a string in the cache and isn't tracked as a dependency.\n```\n\n[redis/client.py](https://github.com/redis/redis-py/blob/42f823f85a50473935041bcf6e64a2e7e56d5cdc/redis/client.py#L72) for reference.\n\nLLM \"When the Bug Triggers\" Summary\n\n```\nThe bug triggers when:\n1. **New source files** are added that have no cache\n2. Those files transitively depend on `redis.client` (through some import chain)\n3. `redis.client` is in a fresh SCC that gets loaded\n4. `OpenSSL.SSL` is in a different fresh SCC that is NOT in the current batch\n5. During `fix_cross_refs` for `redis.client`, the lookup for `OpenSSL.SSL.Context` fails\n```\n\nI'm not an expert at the mypy codebase and I've tried to be clear where I'm leaning on LLMs. I'm happy to run any PRs through my internal setup. For transparency -- and not because any human is obliged to read it -- here is a consolidated LLM generated summary: https://gist.github.com/cburroughs/a255831b2780aafe128c500ea43bb4e8\n\n**Your Environment**\n\n- Mypy version used: 1.19.1; `master` at and branched from `67b9c81dd0fa7f3193d6d3448704a01808620158`\n- Mypy command-line flags: `--explicit-package-bases -vv --sqlite-cache`\n- Mypy configuration options from `mypy.ini` (and other config files): Edited sample: https://gist.github.com/cburroughs/6435cc46d75f0fff7ec151a5f580ddc6\n- Python version used: 3.12.12\n- Operating system and version: Linux 6.12.58\n","author":{"url":"https://github.com/cburroughs","@type":"Person","name":"cburroughs"},"datePublished":"2026-01-27T16:23:55Z","url":"https://github.com/python/mypy/issues/20655"}
| 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:d2e52c9a-228d-f91b-0e80-49c6bf626e14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3B0:145630:2E4AE6A:3D4B496:6B00264C |
| html-safe-nonce | 508633f915263269ddb21b67bb613fd2bc00ddcc72768ed31d2f1ab5639de78e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0IwOjE0NTYzMDoyRTRBRTZBOjNENEI0OTY6NkIwMDI2NEMiLCJ2aXNpdG9yX2lkIjoiMzY3NTkwNzU3Mzc5MTMzNjAxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 57e25361cad952f758d2ed047952939123ac1ffedfef6cd16d24a882b3565b8a |
| hovercard-subject-tag | issue:3861371408 |
| 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/20655/issue_layout |
| twitter:image | https://opengraph.githubassets.com/be58b683087fe3619d8bdb4c7bade99a65583e0884f2bd0559819ec4c9398777/python/mypy/issues/20655 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/be58b683087fe3619d8bdb4c7bade99a65583e0884f2bd0559819ec4c9398777/python/mypy/issues/20655 |
| og:image:alt | Crash Report I'm running mypy through the Pants build system on an internal Python monorepo. You can think of Pants as roughly in the vein of Bazel, or Buck2 if you are more familiar with those sys... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cburroughs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width