matangover / mypyls

Mypy language server: runs mypy on Python code to provide type checking, go to definition, and hover.
MIT License
34 stars 5 forks source link

the 'disable_error_code' option is useless #6

Open tjcjc opened 4 years ago

tjcjc commented 4 years ago

I run this cmd ~/.mypyls/bin/pip install -U mypy to update the mypy to 0.79.0 but the dmypy can't read the 'disable_error_code=arg-call' option.

matangover commented 4 years ago

Can you attach your mypy.ini file and the contents of the mypy plugin output in VS Code (in the Output panel)?

tjcjc commented 4 years ago
2020-10-20 19:42:58,662 UTC - INFO - mypyls.python_ls - Starting PythonLanguageServer IO language server
2020-10-20 19:42:58,663 UTC - INFO - mypyls.python_ls - sys.executable = /Users/jasontai/.mypyls/bin/python
2020-10-20 19:42:58,663 UTC - INFO - mypyls.python_ls - sys.version = 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:37:09) 
[Clang 10.0.1 ]
2020-10-20 19:42:58,663 UTC - INFO - mypyls.python_ls - __file__ = /Users/jasontai/.mypyls/lib/python3.7/site-packages/mypyls/python_ls.py
2020-10-20 19:42:58,878 UTC - INFO - mypyls.python_ls - Using non-patched mypy, rich language features not available.
2020-10-20 19:42:58,878 UTC - INFO - mypyls.python_ls - Using Python before 3.8, rich language features not available.
2020-10-20 19:42:58,879 UTC - INFO - mypyls.python_ls - Server capabilities: {'definitionProvider': False, 'hoverProvider': False, 'textDocumentSync': 2}
2020-10-20 19:42:58,910 UTC - INFO - mypyls.config - Updated settings to {'executable': '', 'configFile': '', 'targets': ['.']}
2020-10-20 19:42:58,917 UTC - INFO - mypyls.mypy_server - Got python_executable from pythonPath: /Users/jasontai/miniconda/envs/ml/bin/python
2020-10-20 19:42:58,917 UTC - INFO - mypyls.mypy_server - mypy version: 0.790
2020-10-20 19:42:58,918 UTC - INFO - mypyls.mypy_server - mypyls version: 0.2.3
2020-10-20 19:42:58,918 UTC - INFO - mypyls.mypy_server - Trying to read mypy config file from default locations
2020-10-20 19:42:58,919 UTC - INFO - mypyls.mypy_server - Read mypy config from: .mypy.ini
2020-10-20 19:42:58,919 UTC - INFO - mypyls.mypy_server - python_executable after applying config: /Users/jasontai/miniconda/envs/ml/bin/python
2020-10-20 19:42:58,922 UTC - INFO - mypyls.mypy_server - Checking mypy...
2020-10-20 19:42:58,922 UTC - INFO - mypyls.mypy_server - <mypyls.config.Config object at 0x7fd105240d90>
2020-10-20 19:42:58,923 UTC - INFO - mypyls.mypy_server - Targets: ['/Users/jasontai/project/python/nlp_tutorial/ranking/.']
2020-10-20 19:42:58,922 UTC - INFO - mypyls.mypy_server - Options({'allow_redefinition': False,
 'allow_untyped_globals': False,
 'always_false': [],
 'always_true': [],
 'bazel': False,
 'build_type': 0,
 'cache_dir': '.mypy_cache',
 'cache_fine_grained': True,
 'cache_map': {},
 'check_untyped_defs': True,
 'color_output': True,
 'config_file': '.mypy.ini',
 'custom_typeshed_dir': None,
 'custom_typing_module': None,
 'debug_cache': False,
 'disable_error_code': ['call-arg', 'arg-type'],
 'disabled_error_codes': set(),
 'disallow_any_decorated': False,
 'disallow_any_explicit': False,
 'disallow_any_expr': False,
 'disallow_any_generics': False,
 'disallow_any_unimported': False,
 'disallow_incomplete_defs': False,
 'disallow_subclassing_any': False,
 'disallow_untyped_calls': False,
 'disallow_untyped_decorators': False,
 'disallow_untyped_defs': False,
 'dump_build_stats': False,
 'dump_deps': False,
 'dump_graph': False,
 'dump_inference_stats': False,
 'dump_type_stats': False,
 'enable_error_code': [],
 'enabled_error_codes': set(),
 'error_summary': False,
 'export_types': False,
 'fast_exit': False,
 'files': None,
 'fine_grained_incremental': True,
 'follow_imports': 'normal',
 'follow_imports_for_stubs': False,
 'ignore_errors': False,
 'ignore_missing_imports': True,
 'implicit_reexport': True,
 'incremental': True,
 'junit_xml': None,
 'local_partial_types': True,
 'logical_deps': False,
 'mypy_path': [],
 'mypyc': False,
 'namespace_packages': False,
 'no_implicit_optional': False,
 'no_silence_site_packages': False,
 'no_site_packages': False,
 'package_root': [],
 'pdb': False,
 'per_module_options': {},
 'platform': 'darwin',
 'plugins': [],
 'preserve_asts': False,
 'pretty': False,
 'python_executable': '/Users/jasontai/miniconda/envs/ml/bin/python',
 'python_version': (3, 7),
 'quickstart_file': None,
 'raise_exceptions': True,
 'report_dirs': {},
 'scripts_are_modules': False,
 'semantic_analysis_only': False,
 'shadow_file': None,
 'show_absolute_path': False,
 'show_column_numbers': True,
 'show_error_codes': True,
 'show_error_context': False,
 'show_none_errors': True,
 'show_traceback': True,
 'skip_cache_mtime_checks': False,
 'skip_version_check': False,
 'sqlite_cache': False,
 'strict_equality': False,
 'strict_optional': True,
 'strict_optional_whitelist': None,
 'transform_source': None,
 'unused_configs': set(),
 'use_builtins_fixtures': False,
 'use_fine_grained_cache': True,
 'verbosity': 0,
 'warn_incomplete_stub': False,
 'warn_no_return': True,
 'warn_redundant_casts': False,
 'warn_return_any': False,
 'warn_unreachable': False,
 'warn_unused_configs': False,
 'warn_unused_ignores': False})

The mypy output info is upside. I also debuged the mypy_server options in mypyls. The .mypy.ini:

[mypy]
ignore_missing_imports=True
show_column_numbers=True
show_error_codes=True
disable_error_code=call-arg,arg-type
matangover commented 4 years ago

Thanks for the details. After some debugging I realized this is indeed a bug in mypyls. Mypy has code in mypy.main.process_options that mypyls never calls, so the list of disabled error codes is not initialized. I could solve this issue specifically but the root cause is that mypyls is using mypy in an unsupported way. What I really want to do is avoid mypyls completely and use dmypy directly.

matangover commented 3 years ago

@tjcjc hi! You can test the beta version of the mypy-vscode extension which now supports disable_error_code. See here: https://github.com/matangover/mypy-vscode/issues/27