Giter Site home page Giter Site logo

Comments (15)

gatesn avatar gatesn commented on May 29, 2024

@mikn Agree mypy would be a nice addition. But given mypy is Python 3 only (to run the type checking at least) I would recommend creating a plugin.

Happy to help out with this if you wanted to kick on off? Essentially you'll need to create a 'pyls' entry point. See https://pluggy.readthedocs.io for more information, and see pyls/hookspecs.py for information on which hooks you can implement.

The built-in functionality is implemented as plugins as well so you can see how those are created.

from python-language-server.

mikn avatar mikn commented on May 29, 2024

Right! I made a rough pull request! I just want to clarify: mypy runs very well on Python 2 as well. If you want to go hard core, there's a typing package on pypi (https://pypi.python.org/pypi/typing) for 2.7+. I do not think there's a problem to leave this active in most cases as even without the typing library, it will try to do type inference for you and warn you of 'dict does not have append' etc. :)

from python-language-server.

gatesn avatar gatesn commented on May 29, 2024

from python-language-server.

ethanhs avatar ethanhs commented on May 29, 2024

Mypy has a runtime requirement of Python 3.3+, but can typecheck Python 2.7 & 3.3+.

from python-language-server.

gatesn avatar gatesn commented on May 29, 2024

from python-language-server.

tomv564 avatar tomv564 commented on May 29, 2024

Are you suggesting creating a new python3-language-service package?

I took the branch from the PR, rebased it and and added version requirements so mypy functionality is optional: develop...tomv564:mypy_lint

Tox installs and tests pass (with coverage on mypy_lint only on python 3.2 or better)
@gatesn: Would this solution be workable?
@mikn: Do you want a PR against your branch so we can use the existing PR?

from python-language-server.

gatesn avatar gatesn commented on May 29, 2024

No, I mean create a new repository entirely called e.g. "pyls-mypy". Then in setup.py, create an entry point:

    entry_points={
        'pyls': [
            'pyls_mypy = pyls_mypy.plugin',
        ],
    },

Then in plugin.py:

from pyls import hookimpl

@hookimpl
def pyls_lint(document):
    return [{
        'range': {...},
        'message': "The linting message to include",
        'source': 'mypy'
    }]

Then also in the setup.py, take a dependency on python-language-server and Python >= 3

from python-language-server.

gatesn avatar gatesn commented on May 29, 2024

Then as long as it's installed in the same environment, pyls will pick up the plugin.

from python-language-server.

tomv564 avatar tomv564 commented on May 29, 2024

Thanks for explaining, I found pluggy's load_setuptools_entrypoints feature now.
I'll have a look, or perhaps @mikn did some of this work already!

from python-language-server.

tomv564 avatar tomv564 commented on May 29, 2024

Mypy plugin now lives at https://github.com/tomv564/pyls-mypy.
It is not published yet, would appreciate testing / comments before I do!

from python-language-server.

tomv564 avatar tomv564 commented on May 29, 2024

Package is now published as pyls-mypy

from python-language-server.

gatesn avatar gatesn commented on May 29, 2024

Awesome, thanks for this! Just need a nicer way to disable pyflakes / pep8 in favour of this now.

from python-language-server.

 avatar commented on May 29, 2024

FYI pyflakes/pep8 and mypy are completely different creatures. Mypy is static typing, no overlap with any of the other linters.

from python-language-server.

gatesn avatar gatesn commented on May 29, 2024

You're right... not sure what I was thinking there

from python-language-server.

gatesn avatar gatesn commented on May 29, 2024

Closing since https://pypi.python.org/pypi/pyls-mypy/0.1.2 exists

from python-language-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.