Skip to content

Commit

Permalink
Merge pull request #257 from galaxyproject/update_server_dependencies
Browse files Browse the repository at this point in the history
Update server dependencies + improve development experience
  • Loading branch information
davelopez authored Aug 17, 2024
2 parents d5628a3 + 6cfdb58 commit 91968ef
Show file tree
Hide file tree
Showing 34 changed files with 163 additions and 112 deletions.
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

10 changes: 3 additions & 7 deletions .github/workflows/server-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 .
Expand Down
11 changes: 0 additions & 11 deletions .isort.cfg

This file was deleted.

9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"charliermarsh.ruff",
"ms-python.python",
"ms-python.mypy-type-checker",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker",
]
}
35 changes: 35 additions & 0 deletions .vscode/settings.json.default
Original file line number Diff line number Diff line change
@@ -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"
}
}
6 changes: 3 additions & 3 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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 :)
37 changes: 15 additions & 22 deletions server/galaxyls/server.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion server/galaxyls/services/completion.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Module in charge of the auto-completion feature."""

from typing import (
cast,
List,
Optional,
cast,
)

from lsprotocol.types import (
Expand All @@ -22,6 +22,7 @@
XmlCDATASection,
XmlElement,
)

from ..config import CompletionMode
from ..types import AutoCloseTagResult
from .context import XmlContext
Expand Down
2 changes: 1 addition & 1 deletion server/galaxyls/services/context.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
1 change: 1 addition & 0 deletions server/galaxyls/services/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
RefactorMacrosService,
)
from galaxyls.services.tools.testing import ToolTestsDiscoveryService

from ..config import CompletionMode
from ..types import (
GeneratedSnippetResult,
Expand Down
2 changes: 1 addition & 1 deletion server/galaxyls/services/tools/document.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path
from typing import (
cast,
Dict,
List,
Optional,
cast,
)

from anytree import find # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion server/galaxyls/services/tools/generators/command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import (
cast,
List,
Optional,
Tuple,
Union,
cast,
)

from anytree import PreOrderIter # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions server/galaxyls/services/tools/generators/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
abstractmethod,
)
from typing import (
cast,
List,
Optional,
Tuple,
Union,
cast,
)

from galaxy.util import xml_macros
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions server/galaxyls/services/tools/generators/tests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import (
cast,
List,
Optional,
Tuple,
Union,
cast,
)

from lsprotocol.types import (
Expand Down Expand Up @@ -32,7 +32,6 @@
HAS_TEXT,
INPUTS,
LINE,
N,
NAME,
OPTION,
OUTPUT,
Expand All @@ -48,6 +47,7 @@
TOOL,
TYPE,
VALUE,
N,
)
from galaxyls.services.tools.document import GalaxyToolXmlDocument
from galaxyls.services.tools.generators.snippets import SnippetGenerator
Expand Down
4 changes: 2 additions & 2 deletions server/galaxyls/services/tools/inputs.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions server/galaxyls/services/tools/linting.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 3 additions & 2 deletions server/galaxyls/services/xml/document.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import (
Any,
cast,
Dict,
List,
Optional,
cast,
)

from anytree.search import findall # type: ignore
Expand All @@ -16,6 +16,7 @@
from pygls.workspace import Document

from galaxyls.constants import DEFAULT_DOCUMENT_RANGE

from .nodes import (
XmlContainerNode,
XmlElement,
Expand Down Expand Up @@ -70,7 +71,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

Expand Down
4 changes: 2 additions & 2 deletions server/galaxyls/services/xml/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
abstractmethod,
)
from typing import (
cast,
Dict,
List,
Optional,
Tuple,
cast,
)

from anytree import NodeMixin # type: ignore
Expand Down Expand Up @@ -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):
Expand Down
18 changes: 3 additions & 15 deletions server/galaxyls/services/xml/parser.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
""" 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,
)
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

Expand All @@ -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.
Expand Down
Loading

0 comments on commit 91968ef

Please sign in to comment.