From b97204157d4ae787414c4fd449bb70cce8726cb5 Mon Sep 17 00:00:00 2001 From: Francesco Bertolaccini Date: Tue, 9 Apr 2024 11:43:04 +0200 Subject: [PATCH] Format --- slither_lsp/app/logging/lsp_handler.py | 1 + slither_lsp/app/request_handlers/types.py | 2 +- slither_lsp/app/slither_server.py | 6 +++--- slither_lsp/app/utils/file_paths.py | 10 ++++------ slither_lsp/app/utils/ranges.py | 4 +++- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/slither_lsp/app/logging/lsp_handler.py b/slither_lsp/app/logging/lsp_handler.py index 47e92db..b1b8441 100644 --- a/slither_lsp/app/logging/lsp_handler.py +++ b/slither_lsp/app/logging/lsp_handler.py @@ -16,6 +16,7 @@ class LSPHandler(Handler): """ Forwards log messages to the LSP client """ + def __init__(self, server: LanguageServer): Handler.__init__(self) self.server = server diff --git a/slither_lsp/app/request_handlers/types.py b/slither_lsp/app/request_handlers/types.py index d17fe46..68d052b 100644 --- a/slither_lsp/app/request_handlers/types.py +++ b/slither_lsp/app/request_handlers/types.py @@ -19,4 +19,4 @@ def to_pos(pos: lsp.Position) -> Pos: def to_range(range: lsp.Range) -> Range: - return (to_pos(range.start), to_pos(range.end)) \ No newline at end of file + return (to_pos(range.start), to_pos(range.end)) diff --git a/slither_lsp/app/slither_server.py b/slither_lsp/app/slither_server.py index b12a05e..73f3eac 100644 --- a/slither_lsp/app/slither_server.py +++ b/slither_lsp/app/slither_server.py @@ -49,9 +49,9 @@ from slither_lsp.app.utils.file_paths import normalize_uri, uri_to_fs_path # TODO(frabert): Maybe this should be upstreamed? https://github.com/openlawlibrary/pygls/discussions/338 -METHOD_TO_OPTIONS[lsp.WORKSPACE_DID_CHANGE_WATCHED_FILES] = ( - lsp.DidChangeWatchedFilesRegistrationOptions -) +METHOD_TO_OPTIONS[ + lsp.WORKSPACE_DID_CHANGE_WATCHED_FILES +] = lsp.DidChangeWatchedFilesRegistrationOptions class SlitherProtocol(LanguageServerProtocol): diff --git a/slither_lsp/app/utils/file_paths.py b/slither_lsp/app/utils/file_paths.py index e09f97c..3235b15 100644 --- a/slither_lsp/app/utils/file_paths.py +++ b/slither_lsp/app/utils/file_paths.py @@ -6,7 +6,7 @@ def is_solidity_file(path: str) -> bool: filename_base, file_extension = os.path.splitext(path) - return file_extension is not None and file_extension.lower() == '.sol' + return file_extension is not None and file_extension.lower() == ".sol" def uri_to_fs_path(uri: str) -> str: @@ -19,7 +19,7 @@ def normalize_uri(uri: str) -> str: def fs_path_to_uri(path: str) -> str: - uri = urljoin('file:', pathname2url(path)) + uri = urljoin("file:", pathname2url(path)) return uri @@ -41,10 +41,8 @@ def get_solidity_files(folders: Iterable[str], recursive=True) -> Set[str]: solidity_files.add(full_path) elif recursive and os.path.isdir(full_path): # If recursive, join our set with any other discovered files in subdirectories. - if item != 'node_modules': - solidity_files.update( - get_solidity_files([full_path], recursive) - ) + if item != "node_modules": + solidity_files.update(get_solidity_files([full_path], recursive)) # Return all discovered solidity files return solidity_files diff --git a/slither_lsp/app/utils/ranges.py b/slither_lsp/app/utils/ranges.py index db2bd2b..c28dac8 100644 --- a/slither_lsp/app/utils/ranges.py +++ b/slither_lsp/app/utils/ranges.py @@ -48,7 +48,9 @@ def source_to_location(source: Source) -> lsp.Location: ) -def get_object_name_range(obj: Union[Function, Contract, Enum, Event, Structure], comp: CryticCompile) -> lsp.Range: +def get_object_name_range( + obj: Union[Function, Contract, Enum, Event, Structure], comp: CryticCompile +) -> lsp.Range: name_pos = get_definition(obj, comp) return lsp.Range( start=lsp.Position(