Comments (15)
@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.
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.
from python-language-server.
Mypy has a runtime requirement of Python 3.3+, but can typecheck Python 2.7 & 3.3+.
from python-language-server.
from python-language-server.
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.
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.
Then as long as it's installed in the same environment, pyls will pick up the plugin.
from python-language-server.
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.
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.
Package is now published as pyls-mypy
from python-language-server.
Awesome, thanks for this! Just need a nicer way to disable pyflakes / pep8 in favour of this now.
from python-language-server.
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.
You're right... not sure what I was thinking there
from python-language-server.
Closing since https://pypi.python.org/pypi/pyls-mypy/0.1.2 exists
from python-language-server.
Related Issues (20)
- Warning: The engine "vscode" appears to be invalid. HOT 3
- Is this package being deprecated? HOT 4
- Lists are not merged but overriden HOT 1
- AttributeError: 'PosixPath' object has no attribute 'read_text' HOT 2
- Missing support for flake8 --extend-ignore HOT 4
- Unable to start the Python language server
- An issue on workspace/didChangeWorkspaceFolders event HOT 1
- Allow changing severity of flake8 messages HOT 1
- [question] Does python-language-server have a release version suitable for python 3.4? HOT 2
- error pip
- Enable "Discussions"
- Python language server breaks autocomplete on Python 3.11 HOT 4
- Is there a configuration option to enable jumping to `builtin` module stubs? HOT 1
- Crashes due to Pydantic Validation
- Crashes in VS Code due to Pydantic Validation Error HOT 2
- Why no new release after 2020? HOT 1
- Adding from-stdin = false to toml config causes pylint to hang
- How to implement custom completion items through pyi scripts? HOT 1
- Active Fork: python-lsp-server
- mypy cannot locate local packages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-language-server.