tomv564 / pyls-mypy

Mypy plugin for the Python Language Server
MIT License
110 stars 62 forks source link

Skipping analyzing error #43

Closed rwols closed 4 years ago

rwols commented 4 years ago

I never got this right in sublime text:

Screenshot from 2020-04-12 18-19-58

How do I fix this missing imports error? I'm using pyls-mypy version 0.1.8

My project settings are as follows:

{
    "folders":
    [
        {
            "path": "."
        },
        {
            "path": "/home/raoul/.config/sublime-text-3/Packages/LSP-eslint"
        },
        {
            "path": "/home/raoul/.config/sublime-text-3/Packages/metals-sublime"
        },
        {
            "path": "/home/raoul/Documents/Programming/tonic"
        },
        {
            "path": "/home/raoul/.config/sublime-text-3/Packages/User"
        },
        {
            "path": "/home/raoul/.config/sublime-text-3/Packages/lsp_utils"
        },
        {
            "path": "/home/raoul/.config/sublime-text-3/Packages/LSP-json"
        },
        {
            "path": "/home/raoul/.config/sublime-text-3/Packages/UnitTesting"
        },
        {
            "path": "/home/raoul/.config/sublime-text-3/Packages/LSP-vue"
        },
        {
            "path": "../LSP-css"
        },
        {
            "path": "../LSP-html"
        },
        {
            "path": "../LSP-intelephense"
        },
        {
            "path": "../LSP-typescript"
        },
        {
            "path": "../LSP-elm"
        }
    ],
    "settings":
    {
        "rulers":
        [
            120
        ],
        "tab_size": 4,
        "translate_tabs_to_spaces": true,
        "lsp_format_on_save": true,
        "LSP":
        {
            "pyls":
            {
                "command": ["pyls"],
                "scopes": ["source.python"],
                "syntaxes": ["Packages/Python/Python.sublime-syntax"],
                "languageId": "python",
                "env":
                {
                    "PYTHONPATH": "/opt/sublime_text/Lib/python33",
                    "MYPYPATH": "/opt/sublime_text/Lib/python33"
                },
                "enabled": true,
            }
        }
    }
}

I Also tried this env:

                "env":
                {
                    "PYTHONPATH": "/opt/sublime_text/Lib/python33",
                    "MYPYPATH": "/home/raoul/.config/sublime-text-3/Packages/LSP/plugin"
                },

But it doesn't seem to have any effect. I also tried this:

                "env":
                {
                    "PYTHONPATH": "/opt/sublime_text/Lib/python33:/home/raoul/.config/sublime-text-3/Packages/LSP/plugin"
                },

But to no avail.

poppyschmo commented 4 years ago

@rwols, are you able to import plugin.core.edit when running /opt/sublime_text/Lib/python33? If so, try https://github.com/tomv564/pyls-mypy/pull/45 (if you want), removing both env vars and adding

... (stricken)

(or similar) to pyls.settings.pyls. (Guesses based on docs; not a Sublime Text user myself.)

Edit: red herring; bad advice; disregard.

rwols commented 4 years ago

@poppyschmo /opt/sublime_text/Lib/python33 is a folder with two python files sublime_plugin.py and sublime.py. I want mypy to be able to find these two files.

rwols commented 4 years ago

I also want mypy to be able to find ~/.config/sublime-text/Packages/LSP/plugin as that's where .core.edit (core/edit.py) etc lives.

poppyschmo commented 4 years ago

/opt/sublime_text/Lib/python33 is a folder

Yikes. And here I thought it was an exe. Terrible.

Perhaps visitors to this thread more knowledgeable than I may find a working mypy command-line incantation helpful?

poppyschmo commented 4 years ago

@rwols I briefly tried your setup and was able to reproduce the output in your screenshot using your project settings. BTW, I see now that Sublime Text comes with Python embedded. After toggling live_mode off in Packages/User/LSP/sublime-settings, the import errors went away, and the output matched that given by the mypy command in your tox.ini.

sublime_text_mypy

As noted in the README, this means you'll have to save to trigger updates.

rwols commented 4 years ago

Thanks @poppyschmo turning off live-mode indeed works.