Repository navigation
Crash on latest Django Project with dmypy #11456
Copy link
Copy link
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Canot run mypy on latest django, mypy and django-stubs version. started crashin after updating django from 3.2.8 to 3.2.9
Expected Behavior
normal typecheck run
Actual Behavior
crashes with:
Daemon started
Daemon crashed!
Traceback (most recent call last):
File "mypy/dmypy_server.py", line 221, in serve
File "mypy/dmypy_server.py", line 264, in run_command
File "mypy/dmypy_server.py", line 323, in cmd_run
File "mypy/dmypy_server.py", line 380, in check
File "mypy/dmypy_server.py", line 410, in initialize_fine_grained
File "mypy/build.py", line 179, in build
File "mypy/build.py", line 253, in _build
File "mypy/build.py", line 2638, in dispatch
File "mypy/build.py", line 2962, in process_graph
File "mypy/build.py", line 3071, in process_stale_scc
File "mypy/build.py", line 2172, in finish_passes
File "mypy/build.py", line 2220, in update_fine_grained_deps
File "mypy/build.py", line 2211, in compute_fine_grained_deps
File "mypy/server/deps.py", line 114, in get_dependencies
File "mypy/nodes.py", line 305, in accept
File "mypy/server/deps.py", line 176, in visit_mypy_file
File "mypy/traverser.py", line 35, in visit_mypy_file
File "mypy/nodes.py", line 950, in accept
File "mypy/server/deps.py", line 239, in visit_class_def
File "mypy/traverser.py", line 71, in visit_class_def
File "mypy/nodes.py", line 1015, in accept
File "mypy/server/deps.py", line 351, in visit_block
File "mypy/traverser.py", line 39, in visit_block
File "mypy/nodes.py", line 687, in accept
File "mypy/server/deps.py", line 201, in visit_func_def
File "mypy/traverser.py", line 54, in visit_func_def
File "mypy/traverser.py", line 51, in visit_func
File "mypy/nodes.py", line 1015, in accept
File "mypy/server/deps.py", line 351, in visit_block
File "mypy/traverser.py", line 39, in visit_block
File "mypy/nodes.py", line 1073, in accept
File "mypy/server/deps.py", line 403, in visit_assignment_stmt
File "mypy/server/deps.py", line 463, in process_lvalue
File "mypy/server/deps.py", line 495, in get_non_partial_lvalue_type
AssertionError(Write what happened.)
Your Environment
- mypy==0.812
- django-stubs==1.8.0
- Python version used: 3.9.8
- Operating system and version: MacOS 11
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong
Activity
sobolevn commentedon Nov 4, 2021
Please, report it in our repo: https://github.com/typeddjango/django-stubs/
Also:
1.9.0, it might help!Thanks!
Thorbenl commentedon Nov 8, 2021
@sobolevn I will try. Sadly, could only reproduce it on a fresh repo ones, and then it went away. For our project tho, it never goes away, does not matter which version combination i would take with stubs and mypy :( Ima try to pick it out of our giant repo.
christianbundy commentedon Nov 16, 2021
Having the same problem here, it started with a
Pipfile.lockupdate recently and only affects dmypy. We're running [email protected].christianbundy commentedon Nov 17, 2021
@Thorbenl Any chance you have aiohttp as a dependency? I dropped into pdb and here's what I saw:
After bisecting the project history, it looks like aio-libs/aiohttp@a6c7f15 as the problematic commit.
You can repro by creating
mypy.iniin aiohttp with the contents:And running
mypy ..(Technically you don't have to run errors, but this lets you bisect automatically.)
cc: @asvetlov
christianbundy commentedon Nov 17, 2021
Found the problem, although I'm not completely sure why it's a problem:
christianbundy commentedon Nov 17, 2021
Full traceback:
christianbundy commentedon Nov 17, 2021
Minimal repro!
This seems to happen when:
TypeVar(T) has 2+ types.Generic[T]None.🤯
sobolevn commentedon Nov 17, 2021
Btw, this works fine:
The problem reveals itself only if
self.example_attribute = Noneis in place.Great insight, thanks!
christianbundy commentedon Nov 17, 2021
Any ideas on how we might solve it? I haven't contributed to mypy, and honestly I'm not completely sure what purpose this
asserthas in the first place.sobolevn commentedon Nov 17, 2021
It happens here:
I've never touched this part of mypy before. And these lines of code are quite old (4 years):
mypy/mypy/server/deps.py
Lines 487 to 493 in 43eecdb
Git Blame Link
This can either be:
ifbug, where we just forgot to add some conditionsobolevn commentedon Nov 17, 2021
@christianbundy this seems to remove the crash:
But, I am not sure it is correct though. Do you want to send a PR? We can work from there!
Fix `None` assignments with fine-grained cache
christianbundy commentedon Nov 17, 2021
Good idea, thank you!
Fix `None` assignments with fine-grained cache (#11574)
chore: 🤖 avoid an error in vsscode with mypy daemon
Fix `None` assignments with fine-grained cache (python#11574)
chore: 🤖 avoid an error in vsscode with mypy daemon