From 419fef4c1d8fbf0f22574f6881baf065c2eaa956 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 09:47:31 +0200 Subject: [PATCH 01/12] Update lxml and galaxy-tool-util dependencies --- server/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/requirements.txt b/server/requirements.txt index a9cbe07..2f58d34 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -1,4 +1,4 @@ pygls==1.3.1 -lxml==5.2.2 +lxml==5.3.0 anytree==2.12.1 -galaxy-tool-util==24.0.2 +galaxy-tool-util==24.1.1 From b32420d7cdecd9d1f7c5ab06675afffe12c584a5 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:16:26 +0200 Subject: [PATCH 02/12] Update mypy and pytest versions --- server/requirements-dev.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/requirements-dev.txt b/server/requirements-dev.txt index ebc129b..bf418d0 100644 --- a/server/requirements-dev.txt +++ b/server/requirements-dev.txt @@ -7,8 +7,8 @@ flake8-bugbear==24.4.26 flake8==7.0.0 isort==5.13.2 lxml-stubs==0.5.1 -mypy==1.10.0 +mypy==1.11.1 pytest-cov==5.0.0 pytest-mock==3.14.0 -pytest==8.2.0 +pytest==8.3.2 types-setuptools==69.5.0.20240518 From 3933329c59b498d35e162e743e413b318e86a9df Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:22:01 +0200 Subject: [PATCH 03/12] Replace black, flake8 and isort with ruff --- .flake8 | 5 ---- .isort.cfg | 11 ------- server/pyproject.toml | 58 +++++++++++++++++++++++++++++++++++-- server/requirements-dev.txt | 5 +--- 4 files changed, 56 insertions(+), 23 deletions(-) delete mode 100644 .flake8 delete mode 100644 .isort.cfg diff --git a/.flake8 b/.flake8 deleted file mode 100644 index bce3303..0000000 --- a/.flake8 +++ /dev/null @@ -1,5 +0,0 @@ -[flake8] -max-line-length = 127 -ignore = E203, - W503 -max-complexity = 10 \ No newline at end of file diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 8c21281..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[settings] -multi_line_output=3 -include_trailing_comma=true -force_grid_wrap=2 -use_parentheses=true -ensure_newline_before_comments=true -line_length=88 -lexicographical=true -order_by_type=false -known_first_party=galaxyls -no_lines_before=LOCALFOLDER diff --git a/server/pyproject.toml b/server/pyproject.toml index df9f72e..6e60601 100644 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -1,6 +1,6 @@ -[tool.black] -line-length = 127 -target-version = ['py38'] +# ----------------------------------------------------------------------------- +# MyPy configuration +# ----------------------------------------------------------------------------- [tool.mypy] warn_return_any = false @@ -13,3 +13,55 @@ module = [ ] ignore_missing_imports = true + +# ----------------------------------------------------------------------------- +# Ruff configuration +# ----------------------------------------------------------------------------- + +[tool.ruff] +line-length = 127 +indent-width = 4 + +target-version = "py38" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = true + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" + diff --git a/server/requirements-dev.txt b/server/requirements-dev.txt index bf418d0..f45c97d 100644 --- a/server/requirements-dev.txt +++ b/server/requirements-dev.txt @@ -2,10 +2,7 @@ # But imports the runtime ones too -r requirements.txt -black==24.4.2 -flake8-bugbear==24.4.26 -flake8==7.0.0 -isort==5.13.2 +ruff==0.6.1 lxml-stubs==0.5.1 mypy==1.11.1 pytest-cov==5.0.0 From 9d44083545350af9d233bb436810179de3837f64 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:22:25 +0200 Subject: [PATCH 04/12] Fix ruff checks --- server/galaxyls/services/tools/generators/snippets.py | 2 +- server/galaxyls/services/xml/document.py | 2 +- server/galaxyls/services/xml/nodes.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/galaxyls/services/tools/generators/snippets.py b/server/galaxyls/services/tools/generators/snippets.py index cab1cb3..0556195 100644 --- a/server/galaxyls/services/tools/generators/snippets.py +++ b/server/galaxyls/services/tools/generators/snippets.py @@ -43,7 +43,7 @@ def generate_snippet(self) -> GeneratedSnippetResult: if is_error: return GeneratedSnippetResult.as_error(result) insert_position = self._find_snippet_insert_position() - if type(insert_position) == Range: + if type(insert_position) is Range: insert_position = cast(Range, insert_position) return GeneratedSnippetResult(result, insert_position.start, insert_position) insert_position = cast(Position, insert_position) diff --git a/server/galaxyls/services/xml/document.py b/server/galaxyls/services/xml/document.py index 17bf54d..198997e 100644 --- a/server/galaxyls/services/xml/document.py +++ b/server/galaxyls/services/xml/document.py @@ -70,7 +70,7 @@ def root(self) -> Optional[XmlElement]: if len(self.children) == 0: return None try: - return next(child for child in self.children if type(child) == XmlElement) + return next(child for child in self.children if type(child) is XmlElement) except StopIteration: return None diff --git a/server/galaxyls/services/xml/nodes.py b/server/galaxyls/services/xml/nodes.py index 7d4502c..8faeb85 100644 --- a/server/galaxyls/services/xml/nodes.py +++ b/server/galaxyls/services/xml/nodes.py @@ -423,7 +423,7 @@ def get_children_with_name(self, name: str) -> List["XmlElement"]: def get_cdata_section(self) -> Optional["XmlCDATASection"]: """Gets the CDATA node inside this element or None if it doesn't have a CDATA section.""" - return next((node for node in self.children if type(node) == XmlCDATASection), None) + return next((node for node in self.children if type(node) is XmlCDATASection), None) class XmlCDATASection(XmlContainerNode): From 0d670b6b88023d98dee6aa3a39b837a204a5480e Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:52:58 +0200 Subject: [PATCH 05/12] Fix format using ruff --- server/galaxyls/server.py | 37 ++++++++----------- server/galaxyls/services/completion.py | 3 +- server/galaxyls/services/context.py | 2 +- server/galaxyls/services/language.py | 1 + server/galaxyls/services/tools/document.py | 2 +- .../services/tools/generators/command.py | 2 +- .../services/tools/generators/snippets.py | 2 +- .../services/tools/generators/tests.py | 4 +- server/galaxyls/services/tools/inputs.py | 4 +- server/galaxyls/services/tools/linting.py | 4 +- server/galaxyls/services/xml/document.py | 3 +- server/galaxyls/services/xml/nodes.py | 2 +- server/galaxyls/services/xml/parser.py | 4 +- server/galaxyls/services/xml/scanner.py | 2 +- server/galaxyls/services/xml/utils.py | 2 +- server/galaxyls/services/xsd/constants.py | 3 +- server/galaxyls/services/xsd/parser.py | 2 +- server/galaxyls/services/xsd/types.py | 7 ++-- server/galaxyls/services/xsd/validation.py | 3 +- .../tests/integration/tools/test_testing.py | 2 +- .../integration/xml/test_element_node.py | 2 +- server/galaxyls/tests/unit/test_completion.py | 2 +- server/galaxyls/tests/unit/test_context.py | 2 +- server/galaxyls/tests/unit/test_validation.py | 1 + server/galaxyls/types.py | 3 +- 25 files changed, 47 insertions(+), 54 deletions(-) diff --git a/server/galaxyls/server.py b/server/galaxyls/server.py index eb0688c..67e0477 100644 --- a/server/galaxyls/server.py +++ b/server/galaxyls/server.py @@ -1,12 +1,20 @@ -"""Galaxy Tools Language Server implementation -""" +"""Galaxy Tools Language Server implementation""" -from typing import ( - List, - Optional, -) +from typing import List, Optional from lsprotocol.types import ( + INITIALIZED, + TEXT_DOCUMENT_CODE_ACTION, + TEXT_DOCUMENT_COMPLETION, + TEXT_DOCUMENT_DEFINITION, + TEXT_DOCUMENT_DID_CLOSE, + TEXT_DOCUMENT_DID_OPEN, + TEXT_DOCUMENT_DID_SAVE, + TEXT_DOCUMENT_DOCUMENT_LINK, + TEXT_DOCUMENT_DOCUMENT_SYMBOL, + TEXT_DOCUMENT_FORMATTING, + TEXT_DOCUMENT_HOVER, + WORKSPACE_DID_CHANGE_CONFIGURATION, CodeAction, CodeActionKind, CodeActionOptions, @@ -26,33 +34,18 @@ DocumentSymbol, DocumentSymbolParams, Hover, - INITIALIZED, InitializeParams, Location, MessageType, - TEXT_DOCUMENT_CODE_ACTION, - TEXT_DOCUMENT_COMPLETION, - TEXT_DOCUMENT_DEFINITION, - TEXT_DOCUMENT_DID_CLOSE, - TEXT_DOCUMENT_DID_OPEN, - TEXT_DOCUMENT_DID_SAVE, - TEXT_DOCUMENT_DOCUMENT_LINK, - TEXT_DOCUMENT_DOCUMENT_SYMBOL, - TEXT_DOCUMENT_FORMATTING, - TEXT_DOCUMENT_HOVER, TextDocumentIdentifier, TextDocumentPositionParams, TextEdit, - WORKSPACE_DID_CHANGE_CONFIGURATION, WorkspaceConfigurationParams, ) from pygls.server import LanguageServer from pygls.workspace import Document -from galaxyls.config import ( - CompletionMode, - GalaxyToolsConfiguration, -) +from galaxyls.config import CompletionMode, GalaxyToolsConfiguration from galaxyls.constants import Commands from galaxyls.services.language import GalaxyToolLanguageService from galaxyls.services.validation import DocumentValidator diff --git a/server/galaxyls/services/completion.py b/server/galaxyls/services/completion.py index 75e8cfc..1c3ba0d 100644 --- a/server/galaxyls/services/completion.py +++ b/server/galaxyls/services/completion.py @@ -1,9 +1,9 @@ """Module in charge of the auto-completion feature.""" from typing import ( - cast, List, Optional, + cast, ) from lsprotocol.types import ( @@ -22,6 +22,7 @@ XmlCDATASection, XmlElement, ) + from ..config import CompletionMode from ..types import AutoCloseTagResult from .context import XmlContext diff --git a/server/galaxyls/services/context.py b/server/galaxyls/services/context.py index 8c505e1..13db291 100644 --- a/server/galaxyls/services/context.py +++ b/server/galaxyls/services/context.py @@ -1,9 +1,9 @@ """This module provides a service to determine position context inside an XML document.""" from typing import ( - cast, List, Optional, + cast, ) from lsprotocol.types import ( diff --git a/server/galaxyls/services/language.py b/server/galaxyls/services/language.py index 359f4fc..a0834ce 100644 --- a/server/galaxyls/services/language.py +++ b/server/galaxyls/services/language.py @@ -42,6 +42,7 @@ RefactorMacrosService, ) from galaxyls.services.tools.testing import ToolTestsDiscoveryService + from ..config import CompletionMode from ..types import ( GeneratedSnippetResult, diff --git a/server/galaxyls/services/tools/document.py b/server/galaxyls/services/tools/document.py index 64ac373..779a94f 100644 --- a/server/galaxyls/services/tools/document.py +++ b/server/galaxyls/services/tools/document.py @@ -1,9 +1,9 @@ from pathlib import Path from typing import ( - cast, Dict, List, Optional, + cast, ) from anytree import find # type: ignore diff --git a/server/galaxyls/services/tools/generators/command.py b/server/galaxyls/services/tools/generators/command.py index b38bfe4..a26fef8 100644 --- a/server/galaxyls/services/tools/generators/command.py +++ b/server/galaxyls/services/tools/generators/command.py @@ -1,9 +1,9 @@ from typing import ( - cast, List, Optional, Tuple, Union, + cast, ) from anytree import PreOrderIter # type: ignore diff --git a/server/galaxyls/services/tools/generators/snippets.py b/server/galaxyls/services/tools/generators/snippets.py index 0556195..4de62d9 100644 --- a/server/galaxyls/services/tools/generators/snippets.py +++ b/server/galaxyls/services/tools/generators/snippets.py @@ -3,11 +3,11 @@ abstractmethod, ) from typing import ( - cast, List, Optional, Tuple, Union, + cast, ) from galaxy.util import xml_macros diff --git a/server/galaxyls/services/tools/generators/tests.py b/server/galaxyls/services/tools/generators/tests.py index 2b8142b..fa89152 100644 --- a/server/galaxyls/services/tools/generators/tests.py +++ b/server/galaxyls/services/tools/generators/tests.py @@ -1,9 +1,9 @@ from typing import ( - cast, List, Optional, Tuple, Union, + cast, ) from lsprotocol.types import ( @@ -32,7 +32,6 @@ HAS_TEXT, INPUTS, LINE, - N, NAME, OPTION, OUTPUT, @@ -48,6 +47,7 @@ TOOL, TYPE, VALUE, + N, ) from galaxyls.services.tools.document import GalaxyToolXmlDocument from galaxyls.services.tools.generators.snippets import SnippetGenerator diff --git a/server/galaxyls/services/tools/inputs.py b/server/galaxyls/services/tools/inputs.py index 91b7ffb..3f8d191 100644 --- a/server/galaxyls/services/tools/inputs.py +++ b/server/galaxyls/services/tools/inputs.py @@ -1,12 +1,12 @@ from typing import ( - cast, List, Optional, + cast, ) from anytree import ( # type: ignore - find, NodeMixin, + find, ) from galaxyls.services.tools.constants import ( diff --git a/server/galaxyls/services/tools/linting.py b/server/galaxyls/services/tools/linting.py index fcfe574..d7892df 100644 --- a/server/galaxyls/services/tools/linting.py +++ b/server/galaxyls/services/tools/linting.py @@ -1,14 +1,14 @@ from typing import ( - cast, List, + cast, ) from galaxy.tool_util.lint import ( - lint_xml_with, LintContext, LintLevel, LintMessage, XMLLintMessageXPath, + lint_xml_with, ) from lsprotocol.types import ( Diagnostic, diff --git a/server/galaxyls/services/xml/document.py b/server/galaxyls/services/xml/document.py index 198997e..1445289 100644 --- a/server/galaxyls/services/xml/document.py +++ b/server/galaxyls/services/xml/document.py @@ -1,9 +1,9 @@ from typing import ( Any, - cast, Dict, List, Optional, + cast, ) from anytree.search import findall # type: ignore @@ -16,6 +16,7 @@ from pygls.workspace import Document from galaxyls.constants import DEFAULT_DOCUMENT_RANGE + from .nodes import ( XmlContainerNode, XmlElement, diff --git a/server/galaxyls/services/xml/nodes.py b/server/galaxyls/services/xml/nodes.py index 8faeb85..994b9f8 100644 --- a/server/galaxyls/services/xml/nodes.py +++ b/server/galaxyls/services/xml/nodes.py @@ -3,11 +3,11 @@ abstractmethod, ) from typing import ( - cast, Dict, List, Optional, Tuple, + cast, ) from anytree import NodeMixin # type: ignore diff --git a/server/galaxyls/services/xml/parser.py b/server/galaxyls/services/xml/parser.py index edff830..087eabc 100644 --- a/server/galaxyls/services/xml/parser.py +++ b/server/galaxyls/services/xml/parser.py @@ -1,12 +1,12 @@ -""" This code is based on the Eclipse/Lemminx XML language server implementation: +"""This code is based on the Eclipse/Lemminx XML language server implementation: https://github.com/eclipse/lemminx/tree/master/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom Only the minimum subset of the XML dialect used by Galaxy tool wrappers is supported. """ from typing import ( - cast, Optional, + cast, ) from pygls.workspace import Document diff --git a/server/galaxyls/services/xml/scanner.py b/server/galaxyls/services/xml/scanner.py index a7425ed..69d1085 100644 --- a/server/galaxyls/services/xml/scanner.py +++ b/server/galaxyls/services/xml/scanner.py @@ -1,4 +1,4 @@ -""" This code is based on the Eclipse/Lemminx XML language server implementation: +"""This code is based on the Eclipse/Lemminx XML language server implementation: https://github.com/eclipse/lemminx/tree/master/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom Only the minimum subset of the XML dialect used by Galaxy tool wrappers is supported. diff --git a/server/galaxyls/services/xml/utils.py b/server/galaxyls/services/xml/utils.py index 40a6cf4..7b2cdfb 100644 --- a/server/galaxyls/services/xml/utils.py +++ b/server/galaxyls/services/xml/utils.py @@ -1,4 +1,4 @@ -""" This code is based on the Eclipse/Lemminx XML language server implementation: +"""This code is based on the Eclipse/Lemminx XML language server implementation: https://github.com/eclipse/lemminx/tree/master/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/dom Only the minimum subset of the XML dialect used by Galaxy tool wrappers is supported. diff --git a/server/galaxyls/services/xsd/constants.py b/server/galaxyls/services/xsd/constants.py index 2487d25..94bf104 100644 --- a/server/galaxyls/services/xsd/constants.py +++ b/server/galaxyls/services/xsd/constants.py @@ -1,5 +1,4 @@ -"""This module contains constants related to XSD processing. -""" +"""This module contains constants related to XSD processing.""" from pathlib import Path diff --git a/server/galaxyls/services/xsd/parser.py b/server/galaxyls/services/xsd/parser.py index c07e635..f084734 100644 --- a/server/galaxyls/services/xsd/parser.py +++ b/server/galaxyls/services/xsd/parser.py @@ -3,10 +3,10 @@ """ from typing import ( - cast, Dict, List, Optional, + cast, ) from lxml import etree diff --git a/server/galaxyls/services/xsd/types.py b/server/galaxyls/services/xsd/types.py index 02933fe..0e818fc 100644 --- a/server/galaxyls/services/xsd/types.py +++ b/server/galaxyls/services/xsd/types.py @@ -1,20 +1,19 @@ -""" Type definitions for XSD processing. -""" +"""Type definitions for XSD processing.""" from typing import ( Any, - cast, Dict, List, Optional, + cast, ) from anytree import ( # type: ignore - findall, NodeMixin, RenderTree, Resolver, ResolverError, + findall, ) from lsprotocol.types import ( MarkupContent, diff --git a/server/galaxyls/services/xsd/validation.py b/server/galaxyls/services/xsd/validation.py index 8ad3953..575e7cc 100644 --- a/server/galaxyls/services/xsd/validation.py +++ b/server/galaxyls/services/xsd/validation.py @@ -1,5 +1,4 @@ -"""Utilities to validate Galaxy xml tool wrappers. -""" +"""Utilities to validate Galaxy xml tool wrappers.""" from pathlib import Path from typing import List diff --git a/server/galaxyls/tests/integration/tools/test_testing.py b/server/galaxyls/tests/integration/tools/test_testing.py index 42da6a7..ebf5218 100644 --- a/server/galaxyls/tests/integration/tools/test_testing.py +++ b/server/galaxyls/tests/integration/tools/test_testing.py @@ -1,7 +1,7 @@ from typing import ( - cast, Dict, Optional, + cast, ) import pytest diff --git a/server/galaxyls/tests/integration/xml/test_element_node.py b/server/galaxyls/tests/integration/xml/test_element_node.py index b426786..448aa3b 100644 --- a/server/galaxyls/tests/integration/xml/test_element_node.py +++ b/server/galaxyls/tests/integration/xml/test_element_node.py @@ -1,7 +1,7 @@ from typing import ( - cast, List, Tuple, + cast, ) import pytest diff --git a/server/galaxyls/tests/unit/test_completion.py b/server/galaxyls/tests/unit/test_completion.py index 92d916e..5d32816 100644 --- a/server/galaxyls/tests/unit/test_completion.py +++ b/server/galaxyls/tests/unit/test_completion.py @@ -1,6 +1,6 @@ from typing import ( - cast, Optional, + cast, ) import pytest diff --git a/server/galaxyls/tests/unit/test_context.py b/server/galaxyls/tests/unit/test_context.py index 29f7aae..3e8c78a 100644 --- a/server/galaxyls/tests/unit/test_context.py +++ b/server/galaxyls/tests/unit/test_context.py @@ -1,8 +1,8 @@ from typing import ( - cast, List, Optional, Tuple, + cast, ) import pytest diff --git a/server/galaxyls/tests/unit/test_validation.py b/server/galaxyls/tests/unit/test_validation.py index 5e61f11..7904a23 100644 --- a/server/galaxyls/tests/unit/test_validation.py +++ b/server/galaxyls/tests/unit/test_validation.py @@ -2,6 +2,7 @@ from lxml import etree from galaxyls.services.validation import DocumentValidator + from ...services.xsd.constants import TOOL_XSD_FILE from .utils import TestUtils diff --git a/server/galaxyls/types.py b/server/galaxyls/types.py index fe2845e..1c197cf 100644 --- a/server/galaxyls/types.py +++ b/server/galaxyls/types.py @@ -1,5 +1,4 @@ -"""This module contains shared types across all modules. -""" +"""This module contains shared types across all modules.""" from typing import ( Any, From afd114dc3251b44411b05bc4ae98d3c7b3b7db72 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:53:19 +0200 Subject: [PATCH 06/12] Add recommended workspace settings --- .vscode/settings.json.default | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .vscode/settings.json.default diff --git a/.vscode/settings.json.default b/.vscode/settings.json.default new file mode 100644 index 0000000..888258f --- /dev/null +++ b/.vscode/settings.json.default @@ -0,0 +1,35 @@ +{ + "python.analysis.extraPaths": [ + "server" + ], + "[python]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit", + "source.organizeImports": "explicit" + }, + "editor.defaultFormatter": "charliermarsh.ruff" + }, + "python.languageServer": "Pylance", + "python.testing.pytestEnabled": true, + "cSpell.words": [ + "anytree", + "galaxyls", + "galaxytool", + "galaxytools", + "lookpath", + "lsprotocol", + "lxml", + "nsmap", + "pygls" + ], + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + } +} \ No newline at end of file From 9551245d6242c77ccaec5442f0847f6235e49595 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:53:36 +0200 Subject: [PATCH 07/12] Add recommended extensions --- .vscode/extensions.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..d4adbe8 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "charliermarsh.ruff", + "ms-python.python", + "ms-python.mypy-type-checker", + "esbenp.prettier-vscode", + "streetsidesoftware.code-spell-checker", + ] +} \ No newline at end of file From 109d48d7efec3c8d0dfc2d0d924598a2a8fb8d84 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:03:52 +0200 Subject: [PATCH 08/12] Add edam-ontology dependency --- server/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/server/requirements.txt b/server/requirements.txt index 2f58d34..4e79822 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -2,3 +2,4 @@ pygls==1.3.1 lxml==5.3.0 anytree==2.12.1 galaxy-tool-util==24.1.1 +edam-ontology==1.25.2 From 7c63f64abd5355e5caa5d406be58a17478d0deb9 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:10:09 +0200 Subject: [PATCH 09/12] Update server CI linting to use ruff --- .github/workflows/server-ci.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/server-ci.yml b/.github/workflows/server-ci.yml index 0883996..f454921 100644 --- a/.github/workflows/server-ci.yml +++ b/.github/workflows/server-ci.yml @@ -29,12 +29,8 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements-dev.txt - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Lint with ruff + uses: chartboost/ruff-action@v1 - name: Check mypy run: | mypy . From 6a034a99b2505393b807ed1aa2d9125f45b371d3 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:11:41 +0200 Subject: [PATCH 10/12] Update python-version matrix in server CI workflow --- .github/workflows/server-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/server-ci.yml b/.github/workflows/server-ci.yml index f454921..9719824 100644 --- a/.github/workflows/server-ci.yml +++ b/.github/workflows/server-ci.yml @@ -13,7 +13,7 @@ jobs: build: strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: ubuntu-latest defaults: run: From a5b17c2807302cb65ad8061886eb921f000de4d7 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:29:08 +0200 Subject: [PATCH 11/12] Remove unused `flake8: noqa: C901` rule overrides --- server/galaxyls/services/xml/parser.py | 16 ++-------------- server/galaxyls/services/xml/scanner.py | 6 +----- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/server/galaxyls/services/xml/parser.py b/server/galaxyls/services/xml/parser.py index 087eabc..f41490b 100644 --- a/server/galaxyls/services/xml/parser.py +++ b/server/galaxyls/services/xml/parser.py @@ -4,23 +4,12 @@ Only the minimum subset of the XML dialect used by Galaxy tool wrappers is supported. """ -from typing import ( - Optional, - cast, -) +from typing import Optional, cast from pygls.workspace import Document from .document import XmlDocument -from .nodes import ( - XmlAttribute, - XmlCDATASection, - XmlComment, - XmlContent, - XmlElement, - XmlProcessingInstruction, - XmlSyntaxNode, -) +from .nodes import XmlAttribute, XmlCDATASection, XmlComment, XmlContent, XmlElement, XmlProcessingInstruction, XmlSyntaxNode from .scanner import XmlScanner from .types import TokenType @@ -31,7 +20,6 @@ class XmlDocumentParser: If the document is incomplete or malformed, the parser will try to recover the syntax tree in those cases without altering the original offsets of the nodes.""" - # flake8: noqa: C901 def parse(self, document: Document) -> XmlDocument: """Parses the given text document and returns the resulting syntax tree as a XmlDocument. diff --git a/server/galaxyls/services/xml/scanner.py b/server/galaxyls/services/xml/scanner.py index 69d1085..21eba8e 100644 --- a/server/galaxyls/services/xml/scanner.py +++ b/server/galaxyls/services/xml/scanner.py @@ -21,10 +21,7 @@ PI_END_CHAR_SEQ, QUOTE_CHARS, ) -from .types import ( - ScannerState, - TokenType, -) +from .types import ScannerState, TokenType from .utils import MultiLineStream ERROR_UNEXPECTED_WHITESPACE = "Unexpected whitespace. Tag name must directly follow the open angle bracket." @@ -72,7 +69,6 @@ def _finish_token(self, offset: int, type: TokenType, error_message: Optional[st self.token_error = error_message return type - # flake8: noqa: C901 def _internal_scan(self) -> TokenType: """Scans the document for the next token. From 6cfdb582730b357c98339b40b6cea4869542bcb5 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Sat, 17 Aug 2024 11:30:08 +0200 Subject: [PATCH 12/12] Update CONTRIBUTING.md to use ruff for linting --- docs/CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 3e192b4..c74d051 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -144,7 +144,7 @@ If you are using `Windows` we recommend installing and using [WSL](https://docs. 6. When you're done making changes, check that your changes pass ``style linter`` and the ``tests``. ```sh - flake8 + ruff check pytest ``` @@ -184,6 +184,6 @@ Just have a little patience, if everything is in order your pull request will be # Style Guide -Currently the style guide is only defined for the [Language Server](../server) which is writen in ``Python``. +Currently the style guide is only defined for the [Language Server](../server) which is written in ``Python``. -Basically you can rely on [flake8](https://pypi.org/project/flake8/) and [black](https://github.com/psf/black) (along with the configuration files provided in the project directory) to manage all the styling for you. If you installed the [development requirements](../requirements-dev.txt) you already have them installed :) +Basically you can rely on [ruff](https://docs.astral.sh/ruff/) to manage all the styling for you. If you installed the [development requirements](../requirements-dev.txt) you already have them installed :)