GithubHelp home page GithubHelp logo

andrew-christianson / python-language-server-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/python-language-server

0.0 1.0 0.0 5.9 MB

Microsoft Language Server for Python

License: Apache License 2.0

C# 73.59% Python 26.40% PowerShell 0.01%

python-language-server-1's Introduction

Microsoft Python Language Server

Microsoft Python Language Server implements the Language Server Protocol.

Its primary clients are the Python extension for VS Code and Python Tools for Visual Studio.

Feel free to file issues or ask questions on our issue tracker, and we welcome code contributions.

Build/contributing instructions

See CONTRIBUTING.md

Troubleshooting and known issues

See TROUBLESHOOTING.md.

Linting options (diagnostics)

The language server implements diagnostics (or linting), which runs on user code. The following diagnostics are supported:

Code Description
inherit-non-class Attempted to inherit something that is not a class.
too-many-function-arguments Too many arguments have been provided to a function call.
too-many-positional-arguments-before-star Too many arguments have been provided before a starred argument.
no-cls-argument First parameter in a class method must be cls
no-method-argument Method has no arguments
no-self-argument First parameter in a method must be self
parameter-already-specified A argument with this name has already been specified.
parameter-missing A required positional argument is missing.
positional-argument-after-keyword A positional argument has been provided after a keyword argument.
positional-only-named A positional-only argument (3.8+) has been named in a function call.
return-in-init Encountered an explicit return in __init__ function.
typing-generic-arguments An error occurred while constructing Generic.
typing-newtype-arguments An error occurred while constructing NewType.
typing-typevar-arguments An error occurred while constructing TypeVar.
unknown-parameter-name The keyword argument name provided is unknown.
unresolved-import An import cannot be resolved, and may be missing.
undefined-variable A variable has been used that has not yet been defined.
variable-not-defined-globally A variable is not defined in the global scope.
variable-not-defined-nonlocal A variable is not defined in non-local scopes.

A full list can be seen in the source code.

Linting can be controlled via the user configuration. In VS Code, this is settings.json, but other clients would send this via workspace/didChangeConfiguration.

If python.linting.enabled is set to false in the user configuration, then no diagnostics will be collected other than syntax errors and unresolved imports.

To control the visibility and severity of the diagnotics, there are a number of lists that can be set in the user configuration which make use of each diagnostic's error code.

Setting Description
python.analysis.errors Diagnostics which should be shown as errors.
python.analysis.warnings Diagnostics which should be shown as warnings.
python.analysis.information Diagnostics which should be shown as informational.
python.analysis.disabled Diagnotics which should not be shown at all.

An example of a user configuration which sets these options:

{
    "python.analysis.errors": ["undefined-variable"],
    "python.analysis.warnings": ["unknown-parameter-name"],
    "python.analysis.information": ["unresolved-import"],
    "python.analysis.disabled": ["too-many-function-arguments", "parameter-missing"],
}

Linting can also be controlled on an invidual line basis with a generalized #noqa. Lines with #noqa will have their diagnostic output suppressed.

An example usage:

from python import language_server  # noqa will suppress the linting message for this line

Cache location

During analysis language server produces Python code from compiled modules and builtins which is similar to Python module stubs. It may also produce database files holding module analysis for faster retrieval later. Cache location is at

Windows

"%LOCALAPPDATA%\Microsoft\Python Language Server" (which is Environment.SpecialFolder.LocalApplicationData). Typically "C:\Users\\%USER_NAME%\AppData\Local\Microsoft\Python Language Server"

Linux

"$XDG_CACHE_HOME/Microsoft/Python Language Server", or if XDG_CACHE_HOME is not set, "$HOME/.cache/Microsoft/Python Language Server"

macOS

"$HOME/Library/Caches/Microsoft/Python Language Server"

python-language-server-1's People

Contributors

jakebailey avatar alexandersher avatar ctrando avatar brianbok avatar heejaechang avatar lostmsu avatar bschnurr avatar anapo14 avatar jamesralstin avatar dimbleby avatar felixhao28 avatar espositofulvio avatar gramster avatar tinysun212 avatar msftgits avatar microsoftopensource avatar rahulkumaran avatar rv404674 avatar thomasgassmann avatar ujjwal-raizada avatar astenman avatar m8mble avatar vigilancer avatar

Watchers

James Cloos avatar

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.