Skip to content

Commit 07499f8

Browse files
committed
Style fixes
1 parent 7ecdfc8 commit 07499f8

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

hdl_checker/lsp.py

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,24 @@
5757
from pygls.uris import from_fs_path, to_fs_path
5858
from tabulate import tabulate
5959

60-
from hdl_checker import DEFAULT_LIBRARY, DEFAULT_PROJECT_FILE
61-
from hdl_checker.config_generators.simple_finder import SimpleFinder
62-
from hdl_checker.core import HdlCheckerCore
63-
from hdl_checker.diagnostics import CheckerDiagnostic, DiagType
64-
from hdl_checker.exceptions import UnknownParameterError
65-
from hdl_checker.parsers.elements.dependency_spec import (
60+
from . import DEFAULT_LIBRARY, DEFAULT_PROJECT_FILE
61+
from .config_generators.simple_finder import SimpleFinder
62+
from .core import HdlCheckerCore
63+
from .diagnostics import CheckerDiagnostic, DiagType
64+
from .exceptions import UnknownParameterError
65+
from .parsers.elements.dependency_spec import (
6666
BaseDependencySpec,
6767
IncludedPath,
6868
RequiredDesignUnit,
6969
)
70-
from hdl_checker.parsers.elements.design_unit import (
70+
from .parsers.elements.design_unit import (
7171
VerilogDesignUnit,
7272
VhdlDesignUnit,
7373
tAnyDesignUnit,
7474
)
75-
from hdl_checker.path import Path, TemporaryPath
76-
from hdl_checker.types import ConfigFileOrigin # , Location
77-
from hdl_checker.utils import (
78-
debounce,
79-
getTemporaryFilename,
80-
logCalls,
81-
onNewReleaseFound,
82-
)
75+
from .path import Path, TemporaryPath
76+
from .types import ConfigFileOrigin # , Location
77+
from .utils import debounce, getTemporaryFilename, logCalls, onNewReleaseFound
8378

8479
_logger = logging.getLogger(__name__)
8580

@@ -136,7 +131,7 @@ class Server(HdlCheckerCore):
136131
def __init__(self, lsp, root_dir):
137132
# type: (LanguageServer, Path) -> None
138133
self._lsp = lsp
139-
super(Server, self).__init__(root_dir)
134+
super().__init__(root_dir)
140135

141136
def _handleUiInfo(self, message):
142137
# type: (...) -> Any
@@ -165,7 +160,7 @@ class HdlCheckerLanguageServer(LanguageServer):
165160

166161
def __init__(self, *args, **kwargs) -> None:
167162
self._checker: Optional[Server] = None
168-
super(HdlCheckerLanguageServer, self).__init__(*args, **kwargs)
163+
super().__init__(*args, **kwargs)
169164
# Default checker
170165
self.onConfigUpdate(None)
171166
self._global_diags: Set[CheckerDiagnostic] = set()
@@ -245,7 +240,8 @@ def onConfigUpdate(self, options: Optional[Any]) -> None:
245240

246241
# Write this to a file and tell the server to use it
247242
auto_project_file = getTemporaryFilename(AUTO_PROJECT_FILE_NAME)
248-
json.dump(config, open(auto_project_file, "w"))
243+
with open(auto_project_file, "w") as fd:
244+
json.dump(config, fd)
249245
self.checker.setConfig(auto_project_file, origin=ConfigFileOrigin.generated)
250246

251247
def _getProjectFilePath(self, options: Optional[Any] = None) -> str:
@@ -509,7 +505,7 @@ def definitions(
509505
# Included paths are dependencies but they're referred to by path, so
510506
# we return a definition to point to the beginning of the file
511507
if isinstance(dependency, IncludedPath):
512-
return [Location(target_uri, Range(Position(0, 0), Position(0, 0),),)]
508+
return [Location(target_uri, Range(Position(0, 0), Position(0, 0)))]
513509

514510
locations: List[Location] = []
515511

@@ -557,9 +553,7 @@ def didSave(self: HdlCheckerLanguageServer, params: DidSaveTextDocumentParams):
557553
self.lint(params.textDocument.uri, True)
558554

559555
@server.feature(TEXT_DOCUMENT_DID_CHANGE)
560-
def didChange(
561-
self: HdlCheckerLanguageServer, params: DidChangeTextDocumentParams,
562-
):
556+
def didChange(self: HdlCheckerLanguageServer, params: DidChangeTextDocumentParams):
563557
"""Text document did change notification."""
564558
self.lint(params.textDocument.uri, False)
565559

@@ -570,25 +564,23 @@ def didOpen(self: HdlCheckerLanguageServer, params: DidOpenTextDocumentParams):
570564

571565
@server.feature(WORKSPACE_DID_CHANGE_CONFIGURATION)
572566
def didChangeConfiguration(
573-
self: HdlCheckerLanguageServer, settings: DidChangeConfigurationParams = None,
567+
self: HdlCheckerLanguageServer, settings: DidChangeConfigurationParams = None
574568
) -> None:
575569
self.onConfigUpdate(settings)
576570

577571
@server.feature(HOVER)
578-
def onHover(
579-
self: HdlCheckerLanguageServer, params: HoverParams,
580-
) -> Optional[Hover]:
572+
def onHover(self: HdlCheckerLanguageServer, params: HoverParams) -> Optional[Hover]:
581573
return self.hover(params)
582574

583575
@server.feature(REFERENCES)
584576
def onReferences(
585-
self: HdlCheckerLanguageServer, params: ReferenceParams,
577+
self: HdlCheckerLanguageServer, params: ReferenceParams
586578
) -> Optional[List[Location]]:
587579
return self.references(params)
588580

589581
@server.feature(DEFINITION)
590582
def onDefinition(
591-
self: HdlCheckerLanguageServer, params: TextDocumentPositionParams,
583+
self: HdlCheckerLanguageServer, params: TextDocumentPositionParams
592584
) -> Optional[List[Location]]:
593585
return self.definitions(params)
594586

0 commit comments

Comments
 (0)