Skip to content

Commit

Permalink
style: reformat code with new black stable style 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
d-biehl committed Jan 26, 2024
1 parent a259ec6 commit b9dbf51
Show file tree
Hide file tree
Showing 63 changed files with 678 additions and 664 deletions.
21 changes: 7 additions & 14 deletions packages/core/src/robotcode/core/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,17 @@


class Lockable(Protocol):
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool:
...
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...

def release(self) -> None:
...
def release(self) -> None: ...

def __enter__(self) -> bool:
...
def __enter__(self) -> bool: ...

def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None:
...
) -> None: ...

def __str__(self) -> str:
...
def __str__(self) -> str: ...


class LockBase:
Expand Down Expand Up @@ -130,13 +125,11 @@ def add_done_callback(self, fn: Callable[["Task[Any]"], Any]) -> None:


@overload
def threaded_task(__func: _F) -> _F:
...
def threaded_task(__func: _F) -> _F: ...


@overload
def threaded_task(*, enabled: bool = True) -> Callable[[_F], _F]:
...
def threaded_task(*, enabled: bool = True) -> Callable[[_F], _F]: ...


def threaded_task(__func: _F = None, *, enabled: bool = True) -> Callable[[_F], _F]:
Expand Down
27 changes: 9 additions & 18 deletions packages/core/src/robotcode/core/documents_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,25 @@ def get_or_open_document(
raise CantReadDocumentError(f"Error reading document '{path}': {e!s}") from e

@event
def on_read_document_text(sender, uri: Uri) -> Optional[str]:
...
def on_read_document_text(sender, uri: Uri) -> Optional[str]: ...

@event
def did_create_uri(sender, uri: DocumentUri) -> None:
...
def did_create_uri(sender, uri: DocumentUri) -> None: ...

@event
def did_create(sender, document: TextDocument) -> None:
...
def did_create(sender, document: TextDocument) -> None: ...

@event
def did_open(sender, document: TextDocument) -> None:
...
def did_open(sender, document: TextDocument) -> None: ...

@event
def did_close(sender, document: TextDocument, full_close: bool) -> None:
...
def did_close(sender, document: TextDocument, full_close: bool) -> None: ...

@event
def did_change(sender, document: TextDocument) -> None:
...
def did_change(sender, document: TextDocument) -> None: ...

@event
def did_save(sender, document: TextDocument) -> None:
...
def did_save(sender, document: TextDocument) -> None: ...

def get(self, _uri: Union[DocumentUri, Uri]) -> Optional[TextDocument]:
with self._lock:
Expand All @@ -137,15 +130,13 @@ def __iter__(self) -> Iterator[DocumentUri]:
return self._documents.__iter__()

@event
def on_document_cache_invalidate(sender, document: TextDocument) -> None:
...
def on_document_cache_invalidate(sender, document: TextDocument) -> None: ...

def _on_document_cache_invalidate(self, sender: TextDocument) -> None:
self.on_document_cache_invalidate(self, sender)

@event
def on_document_cache_invalidated(sender, document: TextDocument) -> None:
...
def on_document_cache_invalidated(sender, document: TextDocument) -> None: ...

def _on_document_cache_invalidated(self, sender: TextDocument) -> None:
self.on_document_cache_invalidated(self, sender)
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/robotcode/core/filewatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def __init__(
self.finalizer: Any = None

@event
def child_callbacks(sender, changes: List[FileEvent]) -> None:
...
def child_callbacks(sender, changes: List[FileEvent]) -> None: ...

def call_childrens(self, sender: Any, changes: List[FileEvent]) -> None:
self.child_callbacks(sender, changes)
Expand All @@ -52,12 +51,10 @@ def add_file_watchers(
self,
callback: Callable[[Any, List[FileEvent]], None],
watchers: List[Union[FileWatcher, str, Tuple[str, Optional[WatchKind]]]],
) -> FileWatcherEntry:
...
) -> FileWatcherEntry: ...

@abstractmethod
def remove_file_watcher_entry(self, entry: FileWatcherEntry) -> None:
...
def remove_file_watcher_entry(self, entry: FileWatcherEntry) -> None: ...


class FileWatcherManagerDummy(FileWatcherManagerBase):
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/robotcode/core/lsp/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6405,9 +6405,9 @@ class SignatureHelpClientCapabilitiesSignatureInformationType(CamelSnakeMixin):
"""Client supports the following content formats for the documentation
property. The order describes the preferred format of the client."""

parameter_information: Optional[
SignatureHelpClientCapabilitiesSignatureInformationTypeParameterInformationType
] = None
parameter_information: Optional[SignatureHelpClientCapabilitiesSignatureInformationTypeParameterInformationType] = (
None
)
"""Client capabilities specific to parameter information."""

active_parameter_support: Optional[bool] = None
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/robotcode/core/text_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,10 @@ def get_lines(self) -> List[str]:
return self._lines

@event
def cache_invalidate(sender) -> None:
...
def cache_invalidate(sender) -> None: ...

@event
def cache_invalidated(sender) -> None:
...
def cache_invalidated(sender) -> None: ...

def _invalidate_cache(self) -> None:
self.cache_invalidate(self)
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/robotcode/core/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class Uri(Mapping[str, str]):
_parts: _Parts

@overload
def __init__(self, uri_str: str):
...
def __init__(self, uri_str: str): ...

@overload
def __init__(
Expand All @@ -60,8 +59,7 @@ def __init__(
params: Optional[str] = None,
query: Optional[str] = None,
fragment: Optional[str] = None,
):
...
): ...

def __init__(
self,
Expand Down
10 changes: 4 additions & 6 deletions packages/core/src/robotcode/core/utils/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,7 @@ def from_dict(
(
(getattr(e, "__name__", None) or str(e) if e is not type(None) else "None")
if _get_origin_cached(e) is not Literal
else repr(e).replace("typing.", "")
if e is not None
else "None"
else repr(e).replace("typing.", "") if e is not None else "None"
)
for e in types
)
Expand Down Expand Up @@ -521,9 +519,9 @@ def _handle_dataclass(value: Any, remove_defaults: bool, encode: bool) -> Dict[s
fields = dataclasses.fields(t)
__dataclasses_cache[t] = fields
return {
encode_case_for_field_name(t, f)
if encode
else f.name: _as_dict_inner(getattr(value, f.name), remove_defaults, encode)
encode_case_for_field_name(t, f) if encode else f.name: _as_dict_inner(
getattr(value, f.name), remove_defaults, encode
)
for f in fields
if not remove_defaults or getattr(value, f.name) != f.default
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/robotcode/core/utils/glob_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def iter_files(
yield from _iter_files_recursive_re(
path=path,
patterns=[] if patterns is None else [p if isinstance(p, Pattern) else Pattern(p) for p in patterns],
ignore_patterns=[]
if ignore_patterns is None
else [p if isinstance(p, Pattern) else Pattern(p) for p in ignore_patterns],
ignore_patterns=(
[] if ignore_patterns is None else [p if isinstance(p, Pattern) else Pattern(p) for p in ignore_patterns]
),
include_hidden=include_hidden,
absolute=absolute,
_base_path=path,
Expand Down
10 changes: 3 additions & 7 deletions packages/core/src/robotcode/core/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ def __init_logger(self) -> LoggingDescriptor:
else (
("" if self.__owner is None else self.__owner.__module__ + "." + self.__owner.__qualname__)
if self.__owner is not None
else get_unwrapped_func(self.__func).__module__
if self.__func is not None
else "<unknown>"
else get_unwrapped_func(self.__func).__module__ if self.__func is not None else "<unknown>"
)
+ self.__postfix
)
Expand Down Expand Up @@ -363,8 +361,7 @@ def set_call_tracing_default_level(cls, level: int) -> None:
cls._call_tracing_default_level = level

@overload
def call(self, _func: _F) -> _F:
...
def call(self, _func: _F) -> _F: ...

@overload
def call(
Expand All @@ -377,8 +374,7 @@ def call(
exiting: bool = False,
exception: bool = False,
timed: bool = False,
) -> Callable[[_F], _F]:
...
) -> Callable[[_F], _F]: ...

def call(
self,
Expand Down
3 changes: 1 addition & 2 deletions packages/debugger/src/robotcode/debugger/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ def step_out(self, thread_id: int, granularity: Optional[SteppingGranularity] =
self.condition.notify_all()

@event
def send_event(sender: Any, event: Event) -> None:
...
def send_event(sender: Any, event: Event) -> None: ...

def set_breakpoints(
self,
Expand Down
3 changes: 1 addition & 2 deletions packages/debugger/src/robotcode/debugger/launcher/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def __init__(
self._transport: Optional[asyncio.BaseTransport] = None

@event
def on_closed(sender) -> None:
...
def on_closed(sender) -> None: ...

@_logger.call
def close(self) -> None:
Expand Down
10 changes: 5 additions & 5 deletions packages/debugger/src/robotcode/debugger/launcher/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,11 @@ async def _launch(
cwd=cwd,
args=[*robotcode_run_args, *run_args],
env=env,
kind=RunInTerminalKind.INTEGRATED
if console == "integratedTerminal"
else RunInTerminalKind.EXTERNAL
if console == "externalTerminal"
else None,
kind=(
RunInTerminalKind.INTEGRATED
if console == "integratedTerminal"
else RunInTerminalKind.EXTERNAL if console == "externalTerminal" else None
),
title=name,
)
),
Expand Down
15 changes: 5 additions & 10 deletions packages/jsonrpc2/src/robotcode/jsonrpc2/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ class RpcMethod(Protocol):


@overload
def rpc_method(_func: _F) -> _F:
...
def rpc_method(_func: _F) -> _F: ...


@overload
Expand All @@ -179,8 +178,7 @@ def rpc_method(
param_type: Optional[Type[Any]] = None,
cancelable: bool = True,
threaded: bool = False,
) -> Callable[[_F], _F]:
...
) -> Callable[[_F], _F]: ...


def rpc_method(
Expand Down Expand Up @@ -389,12 +387,10 @@ def loop(self) -> Optional[asyncio.AbstractEventLoop]:
return self._loop

@event
def on_connection_made(sender, transport: asyncio.BaseTransport) -> None:
...
def on_connection_made(sender, transport: asyncio.BaseTransport) -> None: ...

@event
def on_connection_lost(sender, exc: Optional[BaseException]) -> None:
...
def on_connection_lost(sender, exc: Optional[BaseException]) -> None: ...

def connection_made(self, transport: asyncio.BaseTransport) -> None:
super().connection_made(transport)
Expand Down Expand Up @@ -449,8 +445,7 @@ def data_received(self, data: bytes) -> None:
self._handle_body(body, charset)

@abstractmethod
def _handle_body(self, body: bytes, charset: str) -> None:
...
def _handle_body(self, body: bytes, charset: str) -> None: ...


class JsonRPCProtocol(JsonRPCProtocolBase):
Expand Down
13 changes: 6 additions & 7 deletions packages/jsonrpc2/src/robotcode/jsonrpc2/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ def start(self) -> None:
elif self.mode == ServerMode.SOCKET:
self.start_socket(
self.tcp_params.port,
self.tcp_params.host
if isinstance(self.tcp_params.host, str)
else self.tcp_params.host[0]
if self.tcp_params.host
else None,
(
self.tcp_params.host
if isinstance(self.tcp_params.host, str)
else self.tcp_params.host[0] if self.tcp_params.host else None
),
)
else:
raise JsonRPCException(f"Unknown server mode {self.mode}")
Expand Down Expand Up @@ -166,8 +166,7 @@ def __exit__(
self.close()

@abc.abstractmethod
def create_protocol(self) -> TProtocol:
...
def create_protocol(self) -> TProtocol: ...

stdio_executor: Optional[ThreadPoolExecutor] = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ def collect(
document: TextDocument,
range: Range,
context: CodeActionContext,
) -> Optional[List[Union[Command, CodeAction]]]:
...
) -> Optional[List[Union[Command, CodeAction]]]: ...

@event
def resolve(sender, code_action: CodeAction) -> Optional[CodeAction]:
...
def resolve(sender, code_action: CodeAction) -> Optional[CodeAction]: ...

def extend_capabilities(self, capabilities: ServerCapabilities) -> None:
if len(self.collect):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ def __init__(self, parent: "LanguageServerProtocol") -> None:
self.refresh_timer: Optional[threading.Timer] = None

@event
def collect(sender, document: TextDocument) -> Optional[List[CodeLens]]:
...
def collect(sender, document: TextDocument) -> Optional[List[CodeLens]]: ...

@event
def resolve(sender, code_lens: CodeLens) -> Optional[CodeLens]:
...
def resolve(sender, code_lens: CodeLens) -> Optional[CodeLens]: ...

def extend_capabilities(self, capabilities: ServerCapabilities) -> None:
if len(self.collect):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ def collect(
document: TextDocument,
position: Position,
context: Optional[CompletionContext],
) -> Union[List[CompletionItem], CompletionList, None]:
...
) -> Union[List[CompletionItem], CompletionList, None]: ...

@event
def resolve(sender, completion_item: CompletionItem) -> Optional[CompletionItem]:
...
def resolve(sender, completion_item: CompletionItem) -> Optional[CompletionItem]: ...

def extend_capabilities(self, capabilities: ServerCapabilities) -> None:
if len(self.collect):
Expand Down
Loading

0 comments on commit b9dbf51

Please sign in to comment.