ambitious-student-81104
07/27/2022, 4:26 PMpdb
with ./pants check
? there are some mypy errors that i’d like to drop into pdb to see. Things I’ve tried that didn’t work:
1. adding pdb = True
in mypy.ini
2. adding this in pants.toml
[mypy]
args = ["--pdb"]
bitter-ability-32190
07/27/2022, 4:28 PM./pants --no-process-cleanup check --only=mypy ...
, then look for the logged sandbox dir and crack it open.
There will be a ./__run.sh
you can run to launch the process.
That way you get rid of Pants-in-the-middle and can poke at the process itselfambitious-student-81104
07/27/2022, 4:31 PMbitter-ability-32190
07/27/2022, 4:32 PM--no-process-cleanup
is my favorite little feature. Allows for much debugging and hacking 🙂ambitious-student-81104
07/27/2022, 4:32 PMbitter-ability-32190
07/27/2022, 4:33 PMambitious-student-81104
07/27/2022, 4:34 PMbitter-ability-32190
07/27/2022, 4:34 PMambitious-student-81104
07/27/2022, 4:36 PM❯ ./pants --no-process-cleanup check --only=mypy foo/test.py
12:36:29.56 [ERROR] Completed: Typecheck using MyPy - mypy failed (exit code 1).
cbds/test.py:3:7: error: Module has no attribute "bar" [attr-defined]
print(foo.bar)
^
Found 1 error in 1 file (checked 1 source file)
✕ mypy failed.
bitter-ability-32190
07/27/2022, 4:37 PMambitious-student-81104
07/27/2022, 4:47 PMbitter-ability-32190
07/27/2022, 5:01 PM-linfo
like ./pants -linfo --no-process-cleanup
...freezing-lamp-12123
07/27/2022, 5:05 PM__run.sh
is the real nugget, compared to bazel (last i tried at least) where you had to go through asome steps to get a very complicated shell script to copy/paste and run as a oneliner — always questioned whether or not everything was rightbitter-ability-32190
07/27/2022, 5:06 PM/home/{name}/.cache/bazel/_bazel_{name}/6b497f0d8f4c2590b427029c1f772dc1/execroot/__main__/bazel-out/k8-fastbuild/bin/p1/p2/p3/p4/p5/targetname.runfiles/__main__/p1/p2/p3/p4/p5/filename.py
freezing-lamp-12123
07/27/2022, 5:15 PMhappy-kitchen-89482
07/27/2022, 8:58 PM--pdb
to work even after eliminating Pants and Pex...mypy
command linebitter-ability-32190
07/27/2022, 10:56 PMhappy-kitchen-89482
07/27/2022, 10:58 PMbitter-ability-32190
07/27/2022, 11:01 PMhappy-kitchen-89482
07/27/2022, 11:05 PMambitious-student-81104
07/27/2022, 11:18 PMhappy-kitchen-89482
07/28/2022, 12:25 AM--pdb
do what you want outside of Pants? So far I have notmypy --pdb
on it doesn't have any effect that I can seebitter-ability-32190
07/28/2022, 12:38 AMt = [1, 2, 3, 4]
a, b, c = *t
...
joshuacannon@CEPHANDRIUS:~/work/place$ mypy --strict --pdb foo.py
foo.py:2: error: Can use starred expression only as assignment target
foo.py:2: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
<https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build>
If this issue continues with mypy master, please report a bug at <https://github.com/python/mypy/issues>
version: 0.980+dev.b0e59b29be239ce35cffcef20639709259ee48df
Dropping into pdb
> /home/joshuacannon/.local/pipx/venvs/mypy/lib/python3.8/site-packages/mypy/types.py(2316)accept()
-> assert isinstance(visitor, SyntheticTypeVisitor)
(Pdb)
$ echo -e "t = [1, 2, 3, 4]\na, b, c = *t" > src/python/pants/version2.py
$ ./pants --mypy-args="--pdb" check --only=mypy src/python/pants/version2.py
...
> /tmp/pants-sandbox-1waKR0/mypy/types.py(2289)accept()
(Pdb)
Traceback (most recent call last):
File "mypy/checker.py", line 431, in accept
File "mypy/nodes.py", line 1165, in accept
File "mypy/checker.py", line 2220, in visit_assignment_stmt
File "mypy/checker.py", line 2279, in check_assignment
File "mypy/checker.py", line 2871, in check_assignment_to_multiple_lvalues
File "mypy/checker.py", line 2919, in check_multi_assignment
File "mypy/checker.py", line 3104, in check_multi_assignment_from_iterable
File "mypy/checker.py", line 3097, in type_is_iterable
File "mypy/subtypes.py", line 97, in is_subtype
File "mypy/subtypes.py", line 158, in _is_subtype
File "mypy/types.py", line 2289, in accept
AssertionError:
src/python/pants/version2.py:2: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
<https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build>
Please report a bug at <https://github.com/python/mypy/issues>
version: 0.961
Dropping into pdb
src/python/pants/version2.py:2: : note: use --pdb to drop into pdb
--no-pantsd
happy-kitchen-89482
07/28/2022, 6:12 PM./__mypy_runner.sh
in the sandbox also worksbitter-ability-32190
07/28/2022, 6:27 PM-no-process-cleanup
gets us closeish.
The issue being mypy
isn't unique and could be run in parallel.--pdb
flag? 🤔