leinardi / mypy-pycharm

A plugin providing both real-time and on-demand scanning of Python files with Mypy from within PyCharm/IDEA.
Apache License 2.0
194 stars 31 forks source link

mypy config file is not valid #68

Open eroller opened 3 years ago

eroller commented 3 years ago

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

Steps to reproduce:

  1. Install plugin and restart PyCharm
  2. Test mypy executable in settings (working)
  3. Confirm config file setting automatically set to setup.cfg in my git working directory (i.e. C:/Projects/DragenEngineering/trip_runner2/setup.cfg)
  4. Open mypy tool window and run scan

Observed Results:

Expected Results:

Event Log

9:55 AM Unexpected Exception Caught
                The scan failed due to an exception: mypy config file is not valid. File does not exist or can't be read.
                com.leinardi.pycharm.mypy.exception.MypyPluginException: mypy config file is not valid. File does not exist or can't be read.

                at com.leinardi.pycharm.mypy.mpapi.MypyRunner.getMypyConfigFile(MypyRunner.java:197)

                at com.leinardi.pycharm.mypy.mpapi.MypyRunner.scan(MypyRunner.java:249)

                at com.leinardi.pycharm.mypy.checker.ScanFiles.scan(ScanFiles.java:109)

                at com.leinardi.pycharm.mypy.checker.ScanFiles.checkFiles(ScanFiles.java:100)

                at com.leinardi.pycharm.mypy.checker.ScanFiles.call(ScanFiles.java:74)

                at com.leinardi.pycharm.mypy.MypyInspection.inspectFile(MypyInspection.java:88)

                at com.leinardi.pycharm.mypy.MypyInspection.lambda$checkFile$0(MypyInspection.java:65)

                at com.intellij.openapi.application.impl.ApplicationImpl$1.call(ApplicationImpl.java:2... (show balloon)

Setup,cfg

[mypy]
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_subclassing_any = True
warn_no_return = True
strict_optional = True
strict_equality = True
no_implicit_optional = True
disallow_any_generics = True
disallow_any_unimported = False
warn_redundant_casts = True
warn_unused_ignores = True
warn_unused_configs = True
show_traceback = True
show_error_codes = True
always_false = MYPYC
python_version = 3.7
namespace_packages = True
eroller commented 3 years ago

I found a workaround:

In Mypy PyCharm Settings I removed the auto-filled value in "Path to config file" and added this to the Arguments:

--config-file=C:/Projects/DragenEngineering/trip_runner2/setup.cfg

eroller commented 3 years ago

Some more information about the bug: the file .idea/mypy.xml was:

 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="MypyConfigService">
     <option name="mypyConfigFilePath" value="$PROJECT_DIR$/setup.cfg" />
  </component>
</project>

Perhaps the $PROJECT_DIR$ is not parsed correctly?

Kobu commented 3 years ago

I found a workaround:

In Mypy PyCharm Settings I removed the auto-filled value in "Path to config file" and added this to the Arguments:

--config-file=C:/Projects/DragenEngineering/trip_runner2/setup.cfg

This solved it for me as well