Skip to content

Commit ba69600

Browse files
committed
add some pragmas to no cover parts of code
1 parent 9b0e19f commit ba69600

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

robotcode/language_server/common/lsp_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class SymbolKind(IntEnum):
159159
OPERATOR = 25
160160
TYPEPARAMETER = 26
161161

162-
def __repr__(self) -> str:
162+
def __repr__(self) -> str: # pragma: no cover
163163
return super().__str__()
164164

165165

robotcode/language_server/common/parts/document_symbols.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
from typing import (
55
TYPE_CHECKING,
66
Any,
7+
Callable,
78
List,
89
Optional,
910
Protocol,
11+
TypeVar,
1012
Union,
1113
cast,
1214
runtime_checkable,
@@ -40,6 +42,17 @@ class HasSymbolInformationLabel(Protocol):
4042
symbol_information_label: str
4143

4244

45+
_F = TypeVar("_F", bound=Callable[..., Any])
46+
47+
48+
def symbol_information_label(label: str) -> Callable[[_F], _F]:
49+
def decorator(func: _F) -> _F:
50+
setattr(func, "symbol_information_label", label)
51+
return func
52+
53+
return decorator
54+
55+
4356
class DocumentSymbolsProtocolPart(LanguageServerProtocolPart, HasExtendCapabilities):
4457

4558
_logger = LoggingDescriptor()
@@ -59,9 +72,9 @@ async def collect(
5972
def extend_capabilities(self, capabilities: ServerCapabilities) -> None:
6073

6174
if (
62-
self.parent.client_capabilities is not None
63-
and self.parent.client_capabilities.text_document is not None
64-
and self.parent.client_capabilities.text_document.document_symbol is not None
75+
self.parent.client_capabilities
76+
and self.parent.client_capabilities.text_document
77+
and self.parent.client_capabilities.text_document.document_symbol
6578
):
6679
document_symbol = self.parent.client_capabilities.text_document.document_symbol
6780

robotcode/language_server/common/protocol.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(self, server: JsonRPCServer[Any]):
104104
self._trace = TraceValue.OFF
105105

106106
@async_event
107-
async def on_shutdown(sender) -> None:
107+
async def on_shutdown(sender) -> None: # pragma: no cover
108108
...
109109

110110
@property
@@ -182,15 +182,15 @@ async def _initialize(
182182
)
183183

184184
@async_event
185-
async def on_initialize(sender, initialization_options: Optional[Any] = None) -> None:
185+
async def on_initialize(sender, initialization_options: Optional[Any] = None) -> None: # pragma: no cover
186186
...
187187

188188
@rpc_method(name="initialized", param_type=InitializedParams)
189189
async def _initialized(self, params: InitializedParams) -> None:
190190
await self.on_initialized(self)
191191

192192
@async_event
193-
async def on_initialized(sender) -> None:
193+
async def on_initialized(sender) -> None: # pragma: no cover
194194
...
195195

196196
@rpc_method(name="shutdown")

robotcode/language_server/robotframework/parts/document_symbols.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ....utils.logging import LoggingDescriptor
77
from ...common.language import language_id
88
from ...common.lsp_types import DocumentSymbol, SymbolInformation, SymbolKind
9+
from ...common.parts.document_symbols import symbol_information_label
910
from ...common.text_document import TextDocument
1011
from ..utils.ast import range_from_node
1112

@@ -23,7 +24,7 @@ def __init__(self, parent: RobotLanguageServerProtocol) -> None:
2324

2425
parent.document_symbols.collect.add(self.collect)
2526

26-
@language_id("robotframework")
27+
@language_id("robotframework")
2728
async def collect(
2829
self, sender: Any, document: TextDocument
2930
) -> Optional[Union[List[DocumentSymbol], List[SymbolInformation], None]]:

robotcode/language_server/robotframework/protocol.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
TextDocumentRegistrationOptions,
1414
TextDocumentSyncKind,
1515
)
16+
from ..common.parts.document_symbols import symbol_information_label
1617
from ..common.protocol import LanguageServerProtocol
1718
from .parts.completion import RobotCompletionProtocolPart
1819
from .parts.diagnostics import RobotDiagnosticsProtocolPart
@@ -48,6 +49,7 @@ class Options(Model):
4849
global_storage_uri: Optional[str] = None
4950

5051

52+
@symbol_information_label("robotframework")
5153
class RobotLanguageServerProtocol(LanguageServerProtocol):
5254
_logger = LoggingDescriptor()
5355

@@ -67,8 +69,6 @@ class RobotLanguageServerProtocol(LanguageServerProtocol):
6769
name = "RobotCode"
6870
version = __version__
6971

70-
symbol_information_label = "robotframework"
71-
7272
def __init__(self, server: "RobotLanguageServer"):
7373
super().__init__(server)
7474
self.options = Options()

robotcode/utils/dataclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ def to_camel_case(s: str) -> str:
5757
@runtime_checkable
5858
class HasCaseEncoder(Protocol):
5959
@classmethod
60-
def _encode_case(cls, s: str) -> str:
60+
def _encode_case(cls, s: str) -> str: # pragma: no cover
6161
...
6262

6363

6464
@runtime_checkable
6565
class HasCaseDecoder(Protocol):
6666
@classmethod
67-
def _decode_case(cls, s: str) -> str:
67+
def _decode_case(cls, s: str) -> str: # pragma: no cover
6868
...
6969

7070

0 commit comments

Comments
 (0)