Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyPy crashes if file has changes not yet written to disc #113

Open
2 tasks done
macdjord opened this issue Sep 19, 2023 · 0 comments
Open
2 tasks done

MyPy crashes if file has changes not yet written to disc #113

macdjord opened this issue Sep 19, 2023 · 0 comments

Comments

@macdjord
Copy link

Step 1: Are you in the right place?

  • I have verified there are no duplicate active or recent bugs, questions, or requests
  • I have verified that I am using the latest version of the plugin.

Step 2: Describe your environment

  • Plugin version: 0.16.0
  • PyCharm/IDEA version: PyCharm 2023.2.1 (Community Edition)
  • Mypy version: mypy 1.5.1 (compiled: yes)

Step 3: Describe the problem:

Steps to reproduce:

  1. I open a file and run a scan (either manually or by letting the MyPy inspection run). The scan succeeds and reports various issues.
  2. I make any change to the file whatsoever and then rerun the scan (again, either manually or automatically). The scan fails.
  3. I tab out of PyCharm, causing it to write the changes to disc. When I tab back in, the scan works again.

Observed Results:

Note: I turned off the MyPy inspection for this test, but it has the same error.

  1. Run manual scan of unchanged file (successful):
    • idea.log:
      2023-09-19 18:32:06,373 [505670596]   INFO - #com.leinardi.pycharm.mypy.MypyPlugin - Scanning current file(s).
      2023-09-19 18:32:06,569 [505670792]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Detected Mypy path: C:\Python311\Scripts\mypy.exe
      2023-09-19 18:32:07,199 [505671422]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Detected Mypy path: C:\Python311\Scripts\mypy.exe
      2023-09-19 18:32:07,199 [505671422]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Running command: C:\Python311\Scripts\mypy.exe --show-column-numbers --follow-imports silent --config-file C:\Users\jordan.macdonald\source\sentinel.git\.mypy.ini C:\Users\jordan.macdonald\source\sentinel.git\sentinel-python-base\lib\json_transcoder\_from_json.py
      2023-09-19 18:32:12,327 [505676550]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files
      
  2. Edit file, run manual scan (error):
    • idea.log:
      2023-09-19 18:32:33,030 [505697253]   INFO - #com.leinardi.pycharm.pylint.plapi.PylintRunner - Detected Pylint path: C:\Python311\Scripts\pylint.exe
      2023-09-19 18:32:34,215 [505698438]   INFO - #com.leinardi.pycharm.pylint.plapi.PylintRunner - Detected Pylint path: C:\Python311\Scripts\pylint.exe
      2023-09-19 18:32:35,513 [505699736]   INFO - #com.leinardi.pycharm.pylint.plapi.PylintRunner - Detected Pylint path: C:\Python311\Scripts\pylint.exe
      2023-09-19 18:32:38,981 [505703204]   INFO - #com.leinardi.pycharm.mypy.MypyPlugin - Scanning current file(s).
      2023-09-19 18:32:39,233 [505703456]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Detected Mypy path: C:\Python311\Scripts\mypy.exe
      2023-09-19 18:32:39,803 [505704026]   INFO - #com.leinardi.pycharm.pylint.plapi.PylintRunner - Detected Pylint path: C:\Python311\Scripts\pylint.exe
      2023-09-19 18:32:39,836 [505704059]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Detected Mypy path: C:\Python311\Scripts\mypy.exe
      2023-09-19 18:32:39,837 [505704060]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Running command: C:\Python311\Scripts\mypy.exe --show-column-numbers --follow-imports silent --config-file C:\Users\jordan.macdonald\source\sentinel.git\.mypy.ini C:\Users\JORDAN~1.MAC\AppData\Local\Temp\csi-029\sentinel-python-base\lib\json_transcoder\_from_json.py
      2023-09-19 18:32:40,999 [505705222]   INFO - #com.leinardi.pycharm.pylint.plapi.PylintRunner - Detected Pylint path: C:\Python311\Scripts\pylint.exe
      2023-09-19 18:32:41,203 [505705426]   INFO - #c.i.o.a.i.PopupMenuPreloader - 2009 ms since showing to preload popup menu '' at 'StructureViewPopup(preload-bgt)' in 1 ms
      2023-09-19 18:32:42,118 [505706341]   INFO - #com.leinardi.pycharm.pylint.plapi.PylintRunner - Detected Pylint path: C:\Python311\Scripts\pylint.exe
      2023-09-19 18:33:05,301 [505729524]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files
      
    • Notifications panel:
      Mypy Plugin: Mypy exited abnormally
      
    • Notifications panel:
      Unexpected Exception Caught
      
      The scan failed due to an exception: Mypy failed with code 2 com.leinardi.pycharm.mypy.exception.MypyToolException: Mypy failed with code 2
        at com.leinardi.pycharm.mypy.mpapi.MypyRunner.runMypy(MypyRunner.java:323)
        at com.leinardi.pycharm.mypy.mpapi.MypyRunner.scan(MypyRunner.java:262)
        at com.leinardi.pycharm.mypy.checker.ScanFiles.scan(ScanFiles.java:108)
        at com.leinardi.pycharm.mypy.checker.ScanFiles.checkFiles(ScanFiles.java:99)
        at com.leinardi.pycharm.mypy.checker.ScanFiles.call(ScanFiles.java:73)
        at com.leinardi.pycharm.mypy.checker.ScanFiles.call(ScanFiles.java:45)
        at com.intellij.openapi.application.impl.ApplicationImpl$3.call(ApplicationImpl.java:303)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
        at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
        at java.base/java.lang.Thread.run(Thread.java:833)
      
  3. Tab out of PyCharm, tab back in, run manual scan (successful):
    • idea.log:
      2023-09-19 18:33:29,567 [505753790]   INFO - #com.leinardi.pycharm.mypy.MypyPlugin - Scanning current file(s).
      2023-09-19 18:33:29,752 [505753975]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Detected Mypy path: C:\Python311\Scripts\mypy.exe
      2023-09-19 18:33:30,284 [505754507]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Detected Mypy path: C:\Python311\Scripts\mypy.exe
      2023-09-19 18:33:30,284 [505754507]   INFO - #com.leinardi.pycharm.mypy.mpapi.MypyRunner - Running command: C:\Python311\Scripts\mypy.exe --show-column-numbers --follow-imports silent --config-file C:\Users\jordan.macdonald\source\sentinel.git\.mypy.ini C:\Users\jordan.macdonald\source\sentinel.git\sentinel-python-base\lib\json_transcoder\_from_json.py
      2023-09-19 18:33:34,289 [505758512]   INFO - #c.i.w.i.i.j.s.JpsGlobalModelSynchronizerImpl - Saving global entities to files
      

Note: The notification panel does not give any details, nor report what, if anything, MyPy reported to STDERR before dying. (Or at least I can't find any way to view that information if it does.)

Expected Results:

No error should occur.

Relevant Code:

The failed scan

Notes:

When I try running C:\Python311\Scripts\mypy.exe --show-column-numbers --follow-imports silent --config-file C:\Users\jordan.macdonald\source\sentinel.git\.mypy.ini C:\Users\JORDAN~1.MAC\AppData\Local\Temp\csi-029\sentinel-python-base\lib\json_transcoder\_from_json.py manually in a command window, it fails with this message: mypy: can't read file 'C:\Users\JORDAN~1.MAC\AppData\Local\Temp\csi-029\sentinel-python-base\lib\json_transcoder\_from_json.py': No such file or directory

However, I'm not sure if that's the actual underlying error that happened at the time or if PyCharm just deleted the temporary file after it was done with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant