Repository navigation
"unable to merge overloads" reported from site-packages #12162
Description
Activity
I'm experiencing the same issue. My project
kraken-wrapprdepends onkraken-corewhich vendors a bunch of libraries, such asdill. Dill is not typed nor are there type stubs available. For Mypy checks inkraken-core, I configure Mypy to ignore the dill package like so:# pyproject.toml [[tool.mypy.overrides]] module = "kraken._vendor.dill.*" ignore_errors = true ignore_missing_imports = true
But in the
kraken-wrapperpackage, Mypy spits out an error forkraken._vendor.dill, even though Mypy is only supposed to check thesrc/directory ofkraken-wrapper.mypy| Daemon started mypy| /opt/hostedtoolcache/Python/3.7.13/x64/lib/python3.7/site-packages/kraken/_vendor/dill/__init__.py:287: note: In module imported here, mypy| /opt/hostedtoolcache/Python/3.7.13/x64/lib/python3.7/site-packages/kraken/cli/serialize.py:7: note: ... from here, mypy| /opt/hostedtoolcache/Python/3.7.13/x64/lib/python3.7/site-packages/kraken/cli/main.py:81: note: ... from here, mypy| src/kraken/wrapper/buildenv.py:190: note: ... from here: mypy| /opt/hostedtoolcache/Python/3.7.13/x64/lib/python3.7/site-packages/kraken/_vendor/dill/_dill.py:1409: error: Condition can't be inferred, unable to merge overloads [misc] mypy| if PyTextWrapperType: mypy| ^You can find the CI here: https://github.com/kraken-build/kraken-wrapper/runs/7796703778?check_suite_focus=true
And reproduce it locally with
python3 -m venv .venv source .venv/bin/activate pip install kraken-core==0.8.0 mypy echo "from kraken.cli.main import main" > main.py mypy main.pyGives you
.venv/lib/python3.10/site-packages/kraken/_vendor/dill/_dill.py:1409: error: Condition can't be inferred, unable to merge overloads Found 1 error in 1 file (checked 1 source file)(Mypy 0.971)
Sometimes I also see Mypy checking the site packages as if I passed them as paths to the CLI. I believe I see this mostly with the Mypy daemon though, and restarting it usually fixes it, so it may be slightly unrelated.
Adding this config to
kraken-wrapper'spyproject.tomlfixes the issue, but I would like to avoid that every consumer of the library has to add this to their config.[[tool.mypy.overrides]] module = "kraken._vendor.dill.*" ignore_errors = true
Interestingly, adding
# type: ignoreto the top of the vendored_dill.pydoes not fix it.Similar to NiklasRosenstein's example, there's also a case in
#12299 (comment) where we don't hide errors in third party modules that come from fastparse.
(This was fine when these were hard parse errors, but obviously the line has greyed since then)Some anecdotal findings, I hit this issue in a container running my simply Python application in an image based on
python:3.10.7-slim-bullseye(fe16e9fa64e9). It failed with this error:> pipenv run mypy app --ignore-missing-imports --strict #13 3.564 /root/.local/share/virtualenvs/app-xyz/lib/python3.10/site-packages/numpy/__init__.pyi:636: error: Positional-only parameters are only supported in Python 3.8 and greaterand removing this errror kept spawning further errors in
.pyifiles in thenumpymodule.Changing base image to
python:3.10.6-slim-bullseyeresolved this issuemypy version:
mypy 0.971 (compiled: yes)Reacted by Stegallo, Kyle Harrison, Damien Allen and Eric Vola-HildebrandTechnically unrelated to this, see the pinned issue here #13627
- added 2 commits that reference this issue
on Sep 19, 2022 I'm encountering this error again, and I think it's because my project is compatible with Python 3.7+, but when it is installed in Python 3.10 it get's a newer version of its
markdown-it-pydependency which uses the Walrus operator, hence I get the following in 3.10:/home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/markdown_it/main.py:8: note: In module imported here, /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/markdown_it/__init__.py:5: note: ... from here, /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/rich/markdown.py:6: note: ... from here, /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/rich/__main__.py:8: note: ... from here, /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/rich/pager.py:29: note: ... from here, /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/rich/console.py:59: note: ... from here, /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/httpx/_main.py:10: note: ... from here, /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/httpx/__init__.py:48: note: ... from here, src/kraken/std/http/__init__.py:8: note: ... from here: /home/coder/git/kraken/kraken-build/.venvs/3.11/lib/python3.11/site-packages/markdown_it/common/utils.py:106: error: Assignment expressions are only supported in Python 3.8 and greater [syntax] if pat := DIGITAL_ENTITY_BASE10_RE.fullmatch(name):The following does not fix it:
[[tool.mypy.overrides]] module = "markdown_it.*" ignore_errors = truePinning
markdown-it-py<3.0.0fixes it because Mypy can no longer complain about its 3.10 syntax.- added a commit that references this issue
on Jun 13, 2023 Ah that's unfortunate. If your library still supports Python 3.7, one good way to test is to set up your Python 3.7 environment and run
mypy --python-executable py37venv/bin/python .... Or since mypy still supports Python 3.7 for now (we'll drop support sometime this year), just install mypy into that environment.This will work, because
pipwill avoid installing packages that are unsupported into an environment based on thepython_requiresmetadata. (It might be the case thatmarkdown-it-pydoesn't declarepython_requirescorrectly, in which case manually pinning is your only option)- changed the title
[-]MyPy Reporting problems in dependencies (site-packages)[/-][+]"unable to merge overloads" reported from site-packages[/+]on Oct 14, 2024 Several different things have been discussed or fixed in this issue and it's no longer clear to me what is still an issue and if so, what repros for those are.
If you have a syntax error in a third party package that mypy checks, that will be reported and treated as a blocking error. In that case, your best option is to tell mypy to never look at the offending module, e.g. with:
[mypy-faulty_module.*] follow_imports = skipIf you encounter another situation where you're getting errors from a third party package, please open a new issue.
- added a commit that references this issue
on Sep 23, 2025
Bug Report
MyPy is reporting problems with dependencies in site-packages.
To Reproduce
To be honest, I'm having trouble reproducing a minimal example I can share. I don't understand why it's reporting on site-packages in the first place.
Expected Behavior
MyPy should only tell me about errors in the code I tell it to check - not it's dependencies.
Actual Behavior
.venv/lib/python3.6/site-packages/ddtrace/internal/utils/__init__.py: error: Source file found twice under different module names: "ddtrace.internal.utils" and "ddtrace.internal.utils.__init__"Your Environment
.venv)mypy.ini(and other config files):