Skip to content

Commit 3795762

Browse files
committed
Merge branch 'master' of https://github.com/Moosems/salve
2 parents 2d9805c + cdef951 commit 3795762

4 files changed

Lines changed: 4 additions & 25 deletions

File tree

salve_ipc/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
from beartype.claw import beartype_this_package
2+
13
from .ipc import IPC # noqa: F401
24
from .misc import COMMANDS, Response # noqa: F401
35
from .server_functions import ( # noqa: F401
46
Token,
57
generic_tokens,
68
is_unicode_letter,
79
)
10+
11+
beartype_this_package()

salve_ipc/ipc.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from pathlib import Path
55
from random import randint
66

7-
from beartype import beartype
8-
97
from .misc import COMMANDS, Notification, Request, Response
108
from .server import Server
119

@@ -19,7 +17,6 @@ class IPC:
1917
- IPC.kill_IPC()
2018
"""
2119

22-
@beartype
2320
def __init__(self, id_max: int = 15_000) -> None:
2421
self.all_ids: list[int] = []
2522
self.id_max = id_max
@@ -55,7 +52,6 @@ def create_server(self) -> None:
5552
for filename, data in files_copy.items():
5653
self.update_file(filename, data)
5754

58-
@beartype
5955
def create_message(self, type: str, **kwargs) -> None:
6056
"""Creates a Message based on the args and kwawrgs provided. Highly flexible. - internal API"""
6157
id = randint(1, self.id_max) # 0 is reserved for the empty case
@@ -95,7 +91,6 @@ def create_message(self, type: str, **kwargs) -> None:
9591
}
9692
self.requests_queue.put(notification)
9793

98-
@beartype
9994
def request(
10095
self,
10196
command: str,
@@ -130,7 +125,6 @@ def request(
130125
definition_starters=definition_starters,
131126
)
132127

133-
@beartype
134128
def cancel_request(self, command: str):
135129
"""Cancels a request of type command - external API"""
136130
if command not in COMMANDS:
@@ -141,7 +135,6 @@ def cancel_request(self, command: str):
141135

142136
self.current_ids[command] = 0
143137

144-
@beartype
145138
def parse_response(self, res: Response) -> None:
146139
"""Parses main_server output line and discards useless responses - internal API"""
147140
id = res["id"]
@@ -162,7 +155,6 @@ def check_responses(self) -> None:
162155
while not self.response_queue.empty():
163156
self.parse_response(self.response_queue.get())
164157

165-
@beartype
166158
def get_response(self, command: str) -> Response | None:
167159
"""Runs IPC.check_responses() and returns the current response of type command if it has been returned - external API"""
168160
if command not in COMMANDS:
@@ -176,7 +168,6 @@ def get_response(self, command: str) -> Response | None:
176168
self.newest_responses[command] = None
177169
return response
178170

179-
@beartype
180171
def update_file(self, filename: str, current_state: str) -> None:
181172
"""Updates files in the system - external API"""
182173

@@ -186,7 +177,6 @@ def update_file(self, filename: str, current_state: str) -> None:
186177
"notification", filename=filename, contents=current_state
187178
)
188179

189-
@beartype
190180
def remove_file(self, filename: str) -> None:
191181
"""Removes a file from the main_server - external API"""
192182
if filename not in list(self.files.keys()):

salve_ipc/server.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from multiprocessing.queues import Queue as GenericClassQueue
33
from time import sleep
44

5-
from beartype import beartype
65
from pyeditorconfig import get_config
76

87
from .misc import COMMANDS, Notification, Request, Response
@@ -18,7 +17,6 @@
1817
class Server:
1918
"""Handles input from the user and returns output from special functions designed to make the job easy. Not an external API."""
2019

21-
@beartype
2220
def __init__(
2321
self,
2422
server_end: Connection,
@@ -41,7 +39,6 @@ def __init__(
4139
self.run_tasks()
4240
sleep(0.0025)
4341

44-
@beartype
4542
def simple_id_response(self, id: int, cancelled: bool = True) -> None:
4643
response: Response = {
4744
"id": id,
@@ -50,7 +47,6 @@ def simple_id_response(self, id: int, cancelled: bool = True) -> None:
5047
}
5148
self.response_queue.put(response)
5249

53-
@beartype
5450
def parse_line(self, message: Request | Notification) -> None:
5551
id: int = message["id"]
5652
match message["type"]:
@@ -83,7 +79,6 @@ def cancel_all_ids_except_newest(self) -> None:
8379

8480
self.all_ids = []
8581

86-
@beartype
8782
def handle_request(self, request: Request) -> None:
8883
command: str = request["command"]
8984
id: int = self.newest_ids[command]

salve_ipc/server_functions.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from re import Match, Pattern, compile
33
from unicodedata import category
44

5-
from beartype import beartype
65
from pygments import lex
76
from pygments.lexer import Lexer
87
from pygments.lexers import get_lexer_by_name
@@ -43,7 +42,6 @@
4342
Token = tuple[tuple[int, int], int, str]
4443

4544

46-
@beartype
4745
def get_new_token_type(old_token: str) -> str:
4846
"""Turns pygments token types into a generic predefined Token"""
4947
new_type: str = generic_tokens[0]
@@ -57,7 +55,6 @@ def get_new_token_type(old_token: str) -> str:
5755
url_regex: Pattern = compile(r"(ftp|http|https):\/\/[a-zA-Z0-9_-]")
5856

5957

60-
@beartype
6158
def get_urls(lines: list[str], start_line: int = 1) -> list[Token]:
6259
start_pos: tuple[int, int] = (start_line, 0)
6360
url_toks: list[Token] = []
@@ -149,7 +146,6 @@ def get_urls(lines: list[str], start_line: int = 1) -> list[Token]:
149146
}
150147

151148

152-
@beartype
153149
def find_hidden_chars(lines: list[str], start_line: int = 1) -> list[Token]:
154150
hidden_char_indexes: list[tuple[tuple[int, int], str]] = [
155151
((line_index + start_line, char_index), char)
@@ -163,7 +159,6 @@ def find_hidden_chars(lines: list[str], start_line: int = 1) -> list[Token]:
163159
return tok_list
164160

165161

166-
@beartype
167162
def get_highlights(
168163
full_text: str,
169164
language: str = "text",
@@ -205,13 +200,11 @@ def get_highlights(
205200
return new_tokens
206201

207202

208-
@beartype
209203
def is_unicode_letter(char: str) -> bool:
210204
"""Returns a boolean value of whether a given unicode char is a letter or not (includes "_" for code completion reasons)"""
211205
return char == "_" or category(char).startswith("L")
212206

213207

214-
@beartype
215208
def find_words(full_text: str) -> list[str]:
216209
"""Returns a list of all words in a given piece of text"""
217210
words_list = []
@@ -237,7 +230,6 @@ def find_words(full_text: str) -> list[str]:
237230
return words_list
238231

239232

240-
@beartype
241233
def find_autocompletions(
242234
full_text: str, expected_keywords: list[str], current_word: str
243235
) -> list[str]:
@@ -271,7 +263,6 @@ def find_autocompletions(
271263
return autocomplete_matches
272264

273265

274-
@beartype
275266
def get_replacements(
276267
full_text: str, expected_keywords: list[str], replaceable_word: str
277268
) -> list[str]:
@@ -306,7 +297,6 @@ def get_replacements(
306297
return ranked_matches
307298

308299

309-
@beartype
310300
def get_definition(
311301
full_text: str,
312302
definition_starters: list[tuple[str, str]],

0 commit comments

Comments
 (0)