diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 26a42e7..0000000 --- a/.pylintrc +++ /dev/null @@ -1,214 +0,0 @@ -[MASTER] -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS, .svn, .git, venv - -# Pickle collected data for later comparisons. -persistent=yes - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# pydantic override -extension-pkg-whitelist=pydantic - -[MESSAGES CONTROL] -# can opt to enable instead if you want -disable=logging-format-interpolation - -[REPORTS] - -# Set the output format. Available formats are text, parseable, colorized, msvs -# (visual studio) and html. You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=colorized - -# Tells whether to display a full report or only the messages -reports=no - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[FORMAT] - -# Maximum number of characters on a single line -max-line-length=79 - -# Maximum number of lines in a module -max-module-lines=1000 - -# Indentation uses 4 spaces -indent-string=' ' - - -[BASIC] - -# List of builtins function names that should not be used, separated by a comma -# bad-functions=map,filter,apply - -# Regular expression which should only match correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Regular expression which should only match correct module level names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Regular expression which should only match correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression which should only match correct function names -function-rgx=[a-z_][a-z0-9_]{2,40}$ - -# Regular expression which should only match correct method names -method-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct instance attribute names -attr-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct argument names -argument-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct variable names -variable-rgx=[a-z_][a-z0-9_]{2,30}$ - -# Regular expression which should only match correct list comprehension / -# generator expression variable names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,v,l,_ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Regular expression which should only match functions or classes name which do -# not require a docstring -no-docstring-rgx=__.*__ - - -[SIMILARITIES] - -# Minimum lines number of a similarity. -min-similarity-lines=4 - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - - -[TYPECHECK] - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# List of classes names for which member attributes should not be checked -# (useful for classes with attributes dynamically set). -ignored-classes=SQLObject - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E0201 when accessed. Python regular -# expressions are accepted. -generated-members=REQUEST,acl_users,aq_parent - -ignored-modules=py - - -[VARIABLES] - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# A regular expression matching the beginning of the name of dummy variables -# (i.e. not used). -dummy-variables-rgx=_|dummy - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=5 - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.* - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of statements in function / method body -max-statements=50 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - - -[IMPORTS] - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,string,TERMIOS,Bastion,rexec - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=builtins.Exception diff --git a/README.md b/README.md index ca5e674..4812260 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# jedi-language-server +# Jedi Language Server [![image-version](https://img.shields.io/pypi/v/jedi-language-server.svg)](https://python.org/pypi/jedi-language-server) [![image-license](https://img.shields.io/pypi/l/jedi-language-server.svg)](https://python.org/pypi/jedi-language-server) @@ -11,17 +11,17 @@ A [Python](https://www.python.org/) [Language Server](https://microsoft.github.i ## Installation -Some frameworks, like coc-jedi and vscode-python, will install and manage jedi-language-server for you. If you're setting up manually, you can run the following from your command line (bash / zsh): +Some frameworks, like coc-jedi and vscode-python, will install and manage `jedi-language-server` for you. If you're setting up manually, you can run the following from your command line (bash / zsh): ```bash pip install -U jedi-language-server ``` -Alternatively (and preferably), use [pipx](https://github.com/pipxproject/pipx) to keep jedi-language-server and its dependencies isolated from your other Python dependencies. Don't worry, jedi is smart enough to figure out which Virtual environment you're currently using! +Alternatively (and preferably), use [pipx](https://github.com/pipxproject/pipx) to keep `jedi-language-server` and its dependencies isolated from your other Python dependencies. Don't worry, jedi is smart enough to figure out which Virtual environment you're currently using! ## Editor Setup -The following instructions show how to use jedi-language-server with your development tooling. The instructions assume you have already installed jedi-language-server. +The following instructions show how to use `jedi-language-server` with your development tooling. The instructions assume you have already installed `jedi-language-server`. ### Vim / Neovim @@ -45,13 +45,13 @@ Note: this list is non-exhaustive. If you know of a great choice not included in ### Visual Studio Code (vscode) -Starting from the [October 2021 release](https://github.com/microsoft/vscode-python/releases/tag/2021.10.1317843341), set the `python.languageServer` setting to `Jedi` to use jedi-language-server. +Starting from the [October 2021 release](https://github.com/microsoft/vscode-python/releases/tag/2021.10.1317843341), set the `python.languageServer` setting to `Jedi` to use `jedi-language-server`. See: ## Configuration -jedi-language-server supports the following [initializationOptions](https://microsoft.github.io/language-server-protocol/specification#initialize): +`jedi-language-server` supports the following [initializationOptions](https://microsoft.github.io/language-server-protocol/specification#initialize): ```json { @@ -107,12 +107,12 @@ The different sections of the InitializationOptions are explained below, in deta ### markupKindPreferred -The preferred MarkupKind for all jedi-language-server messages that take [MarkupContent](https://microsoft.github.io/language-server-protocol/specification#markupContent). +The preferred MarkupKind for all `jedi-language-server` messages that take [MarkupContent](https://microsoft.github.io/language-server-protocol/specification#markupContent). - type: `string` - accepted values: `"markdown"`, `"plaintext"` -If omitted, jedi-language-server defaults to the client-preferred configuration. If there is no client-preferred configuration, jedi language server users `"plaintext"`. +If omitted, `jedi-language-server` defaults to the client-preferred configuration. If there is no client-preferred configuration, jedi language server users `"plaintext"`. ### jediSettings.autoImportModules @@ -329,7 +329,7 @@ Disable hover text identified by name in list of jedi-type specified. #### hover.disable.\[jedi-type\].fullNames -Disable hover text identified by the fully qualified name in list of jedi-type specified. If no fully qualified name can be found, jedi-language-server will default to the name to prevent any unexpected behavior for users (relevant for jedi types like keywords that don't have full names). +Disable hover text identified by the fully qualified name in list of jedi-type specified. If no fully qualified name can be found, `jedi-language-server` will default to the name to prevent any unexpected behavior for users (relevant for jedi types like keywords that don't have full names). - type: `string[]` - default: `[]` @@ -390,7 +390,7 @@ Maximum number of symbols returned by a call to `workspace/symbols`. } ``` -A value less than or equal to zero removes the maximum and allows jedi-language-server to return all workplace symbols found by jedi. +A value less than or equal to zero removes the maximum and allows `jedi-language-server` to return all workplace symbols found by jedi. ### workspace.symbols.ignoreFolders @@ -415,7 +415,7 @@ If you manually set this option, it overrides the default. Setting it to an empt Diagnostics are provided by Python's built-in `compile` function. -If you would like additional diagnostics (from [pylint](https://github.com/PyCQA/pylint), [mypy](https://github.com/python/mypy), etc.), we recommend using other tools (like [diagnostic-language-server](https://github.com/iamcco/diagnostic-languageserver)) to complement `jedi-language-server`. +If you would like additional diagnostics, we recommend using other tools (like [diagnostic-language-server](https://github.com/iamcco/diagnostic-languageserver)) to complement `jedi-language-server`. ## Code Formatting @@ -423,7 +423,7 @@ Again, we recommend that you use [diagnostic-language-server](https://github.com ## Command line usage -jedi-language-server can be run directly from the command line. +`jedi-language-server` can be run directly from the command line. ```console $ jedi-language-server --help @@ -519,9 +519,9 @@ make tests ## Inspiration -Palantir's [python-language-server](https://github.com/palantir/python-language-server) inspired this project. In fact, for consistency's sake, many of python-language-server's CLI options are used as-is in jedi-language-server. +Palantir's [python-language-server](https://github.com/palantir/python-language-server) inspired this project. In fact, for consistency's sake, many of python-language-server's CLI options are used as-is in `jedi-language-server`. -Unlike python-language-server, jedi-language-server: +Unlike python-language-server, `jedi-language-server`: - Uses [pygls](https://github.com/openlawlibrary/pygls) instead of creating its own low-level Language Server Protocol bindings - Supports one powerful 3rd party static analysis / completion / refactoring library: Jedi. By only supporting Jedi, we can focus on supporting all Jedi features without exposing ourselves to too many broken 3rd party dependencies (I'm looking at you, [rope](https://github.com/python-rope/rope)). diff --git a/jedi_language_server/initialization_options.py b/jedi_language_server/initialization_options.py index b7f522d..374ad4d 100644 --- a/jedi_language_server/initialization_options.py +++ b/jedi_language_server/initialization_options.py @@ -13,12 +13,7 @@ from cattrs.gen import make_dict_structure_fn, override from lsprotocol.types import MarkupKind -# pylint: disable=invalid-field-call -# pylint: disable=missing-class-docstring -# pylint: disable=too-few-public-methods - if sys.version_info >= (3, 10): - # pylint: disable-next=unexpected-keyword-arg light_dataclass = dataclass(kw_only=True, eq=False, match_args=False) else: light_dataclass = dataclass(eq=False) diff --git a/jedi_language_server/jedi_utils.py b/jedi_language_server/jedi_utils.py index 12fca01..0dbd525 100644 --- a/jedi_language_server/jedi_utils.py +++ b/jedi_language_server/jedi_utils.py @@ -85,7 +85,7 @@ def run() -> None: def _jedi_debug_function( - color: str, # pylint: disable=unused-argument + color: str, str_out: str, ) -> None: """Jedi debugging function that prints to stderr. @@ -95,7 +95,7 @@ def _jedi_debug_function( print(str_out, file=sys.stderr) -def set_jedi_settings( # pylint: disable=invalid-name +def set_jedi_settings( initialization_options: InitializationOptions, ) -> None: """Sets jedi settings.""" @@ -200,7 +200,6 @@ def lsp_document_symbols(names: List[Name]) -> List[DocumentSymbol]: accessible with dot notation are removed from display. See comments inline for cleaning steps. """ - # pylint: disable=too-many-branches _name_lookup: Dict[Name, DocumentSymbol] = {} results: List[DocumentSymbol] = [] for name in names: @@ -454,7 +453,6 @@ def is_import(script_: Script, line: int, column: int) -> bool: completions, without any text, which will may cause issues for users with manually triggered completions. """ - # pylint: disable=protected-access tree_name = script_._module_node.get_name_of_position((line, column)) if tree_name is None: return False @@ -478,7 +476,7 @@ def clear_completions_cache() -> None: _MOST_RECENT_COMPLETIONS.clear() -def lsp_completion_item( # pylint: disable=too-many-arguments +def lsp_completion_item( completion: Completion, char_before_cursor: str, enable_snippets: bool, @@ -516,7 +514,7 @@ def lsp_completion_item( # pylint: disable=too-many-arguments try: snippet_signature = get_snippet_signature(signatures[0]) - except Exception: # pylint: disable=broad-except + except Exception: return completion_item new_text = completion_name + snippet_signature completion_item.insert_text = new_text @@ -575,7 +573,7 @@ def convert_docstring(docstring: str, markup_kind: MarkupKind) -> str: return docstring_to_markdown.convert(docstring_stripped).strip() except docstring_to_markdown.UnknownFormatError: return _md_text(docstring_stripped, markup_kind) - except Exception as error: # pylint: disable=broad-except + except Exception as error: result = ( docstring_stripped + "\n" @@ -653,7 +651,6 @@ def hover_text( initialization_options: InitializationOptions, ) -> Optional[str]: """Get a hover string from a list of names.""" - # pylint: disable=too-many-branches if not names: return None name = names[0] diff --git a/jedi_language_server/server.py b/jedi_language_server/server.py index 3c10f9f..77e6d00 100644 --- a/jedi_language_server/server.py +++ b/jedi_language_server/server.py @@ -201,7 +201,6 @@ def completion( server: JediLanguageServer, params: CompletionParams ) -> Optional[CompletionList]: """Returns completion items.""" - # pylint: disable=too-many-locals snippet_disable = server.initialization_options.completion.disable_snippets resolve_eagerly = server.initialization_options.completion.resolve_eagerly ignore_patterns = server.initialization_options.completion.ignore_patterns @@ -628,8 +627,8 @@ def code_action( @SERVER.feature(WORKSPACE_DID_CHANGE_CONFIGURATION) def did_change_configuration( - server: JediLanguageServer, # pylint: disable=unused-argument - params: DidChangeConfigurationParams, # pylint: disable=unused-argument + server: JediLanguageServer, + params: DidChangeConfigurationParams, ) -> None: """Implement event for workspace/didChangeConfiguration. @@ -667,8 +666,8 @@ def did_save_diagnostics( def did_save_default( - server: JediLanguageServer, # pylint: disable=unused-argument - params: DidSaveTextDocumentParams, # pylint: disable=unused-argument + server: JediLanguageServer, + params: DidSaveTextDocumentParams, ) -> None: """Actions run on textDocument/didSave: default.""" @@ -682,8 +681,8 @@ def did_change_diagnostics( def did_change_default( - server: JediLanguageServer, # pylint: disable=unused-argument - params: DidChangeTextDocumentParams, # pylint: disable=unused-argument + server: JediLanguageServer, + params: DidChangeTextDocumentParams, ) -> None: """Actions run on textDocument/didChange: default.""" @@ -697,8 +696,8 @@ def did_open_diagnostics( def did_open_default( - server: JediLanguageServer, # pylint: disable=unused-argument - params: DidOpenTextDocumentParams, # pylint: disable=unused-argument + server: JediLanguageServer, + params: DidOpenTextDocumentParams, ) -> None: """Actions run on textDocument/didOpen: default.""" @@ -712,8 +711,8 @@ def did_close_diagnostics( def did_close_default( - server: JediLanguageServer, # pylint: disable=unused-argument - params: DidCloseTextDocumentParams, # pylint: disable=unused-argument + server: JediLanguageServer, + params: DidCloseTextDocumentParams, ) -> None: """Actions run on textDocument/didClose: default.""" diff --git a/jedi_language_server/text_edit_utils.py b/jedi_language_server/text_edit_utils.py index d82fa8e..2baac1f 100644 --- a/jedi_language_server/text_edit_utils.py +++ b/jedi_language_server/text_edit_utils.py @@ -146,7 +146,6 @@ def get_opcodes(old: str, new: str) -> List[Opcode]: return [Opcode(*opcode) for opcode in diff.get_opcodes()] -# pylint: disable=too-few-public-methods class PositionLookup: """Data structure to convert byte offset file to line number and character.""" diff --git a/tests/lsp_test_client/defaults.py b/tests/lsp_test_client/defaults.py index cf48126..c371408 100644 --- a/tests/lsp_test_client/defaults.py +++ b/tests/lsp_test_client/defaults.py @@ -4,7 +4,7 @@ import tests.lsp_test_client as lsp_client VSCODE_DEFAULT_INITIALIZE = { - "processId": os.getpid(), # pylint: disable=no-member + "processId": os.getpid(), "clientInfo": {"name": "vscode", "version": "1.45.0"}, "rootPath": str(lsp_client.PROJECT_ROOT), "rootUri": lsp_client.PROJECT_URI, diff --git a/tests/lsp_test_client/session.py b/tests/lsp_test_client/session.py index 82bc33e..36ad89a 100644 --- a/tests/lsp_test_client/session.py +++ b/tests/lsp_test_client/session.py @@ -19,15 +19,12 @@ WINDOW_LOG_MESSAGE = "window/logMessage" WINDOW_SHOW_MESSAGE = "window/showMessage" -# pylint: disable=no-member - class LspSession(MethodDispatcher): """Send and Receive messages over LSP as a test LS Client.""" def __init__(self, cwd=None): self.cwd = cwd if cwd else os.getcwd() - # pylint: disable=consider-using-with self._thread_pool = ThreadPoolExecutor() self._sub = None self._writer = None @@ -40,7 +37,6 @@ def __enter__(self): shell=True needed for pytest-cov to work in subprocess. """ - # pylint: disable=consider-using-with self._sub = subprocess.Popen( [ sys.executable, @@ -74,7 +70,7 @@ def __exit__(self, typ, value, _tb): self.shutdown(True) try: self._sub.terminate() - except Exception: # pylint:disable=broad-except + except Exception: pass self._endpoint.shutdown() self._thread_pool.shutdown() diff --git a/tests/lsp_test_client/utils.py b/tests/lsp_test_client/utils.py index 21e731f..761f7aa 100644 --- a/tests/lsp_test_client/utils.py +++ b/tests/lsp_test_client/utils.py @@ -8,8 +8,6 @@ import py -# pylint: disable=no-member - def normalizecase(path: str) -> str: """Fixes 'file' uri or path case for easier testing in windows.""" diff --git a/tests/lsp_tests/test_completion.py b/tests/lsp_tests/test_completion.py index 8564862..d67f2cc 100644 --- a/tests/lsp_tests/test_completion.py +++ b/tests/lsp_tests/test_completion.py @@ -11,8 +11,6 @@ COMPLETION_TEST_ROOT = TEST_DATA / "completion" -# pylint: disable=line-too-long - def test_lsp_completion() -> None: """Test a simple completion request. @@ -93,7 +91,6 @@ def test_eager_lsp_completion() -> None: } ) - # pylint: disable=line-too-long expected = { "isIncomplete": False, "items": [ @@ -139,7 +136,6 @@ def test_lsp_completion_class_method() -> None: } ) - # pylint: disable=line-too-long expected = { "isIncomplete": False, "items": [ diff --git a/tests/lsp_tests/test_document_symbol.py b/tests/lsp_tests/test_document_symbol.py index b134aad..c9ed85d 100644 --- a/tests/lsp_tests/test_document_symbol.py +++ b/tests/lsp_tests/test_document_symbol.py @@ -11,8 +11,6 @@ SYMBOL_TEST_ROOT = TEST_DATA / "symbol" -# pylint: disable=line-too-long - def test_document_symbol() -> None: """Test document symbol request. diff --git a/tests/lsp_tests/test_hover.py b/tests/lsp_tests/test_hover.py index 953d83c..36ace05 100644 --- a/tests/lsp_tests/test_hover.py +++ b/tests/lsp_tests/test_hover.py @@ -8,8 +8,6 @@ HOVER_TEST_ROOT = TEST_DATA / "hover" -# pylint: disable=line-too-long - def test_hover_on_module(): """Tests hover on the name of a imported module. diff --git a/tests/test_data/hover/somemodule.py b/tests/test_data/hover/somemodule.py index fe9da33..c101260 100644 --- a/tests/test_data/hover/somemodule.py +++ b/tests/test_data/hover/somemodule.py @@ -11,5 +11,5 @@ class SomeClass: def some_method(self): """Method doc string for testing.""" - def some_method2(self): # pylint: disable=missing-function-docstring + def some_method2(self): pass