Skip to content

Commit 309a4e8

Browse files
committed
Update implicit returns
1 parent 2cdebf4 commit 309a4e8

4 files changed

Lines changed: 29 additions & 25 deletions

File tree

build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import sys
1212

1313
assert len(sys.argv) == 2, 'Argument is required, usage: build.py pyinstaller/pip/twine'
14-
mode = sys.argv[1].strip()
15-
sys_arch = struct.calcsize('P') * 8
14+
mode: str = sys.argv[1].strip()
15+
sys_arch: int = struct.calcsize('P') * 8
1616

1717
if mode == 'pyinstaller':
1818
# Check upx
19-
upx = ''
19+
upx: str = ''
2020
if sys.platform == 'win32' and sys_arch == 64:
2121
upx = '--upx-dir specs'
2222
pyinstaller = f'python -m PyInstaller' if sys.platform == 'win32' else 'pyinstaller'

pydetex/_gui_utils.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from pydetex._gui_settings import Settings as _Settings
3737

3838

39+
# noinspection PyTypeChecker
3940
class SettingsWindow(object):
4041
"""
4142
Settings window.
@@ -416,7 +417,7 @@ def _save(self) -> None:
416417
self.close()
417418

418419

419-
# noinspection PyProtectedMember
420+
# noinspection PyProtectedMember,PyTypeChecker
420421
class DictionaryGUI(object):
421422
"""
422423
Dictionary gui.
@@ -562,9 +563,7 @@ def _process_out_key(event: 'tk.Event') -> Optional['tk.Event']:
562563
:param event: Event
563564
:return: Event
564565
"""
565-
# noinspection PyUnresolvedReferences
566-
if event.char == '':
567-
return event
566+
return event if event.char == '' else None
568567

569568
def _get_word(self) -> str:
570569
"""
@@ -633,7 +632,7 @@ def _process(word: str):
633632
self._query_thread(key, _process, self._meaning, self._get_word())
634633
data = self._query_output_pop(key)
635634
if data is None:
636-
return
635+
return None
637636
style, mean, wiki = data
638637
if mean == '':
639638
return self._write(self._cfg.lang('dictionary_no_results'))
@@ -648,6 +647,7 @@ def _process(word: str):
648647
self._text_out.insert('end', f'{self._cfg.lang("dictionary_wikipedia")}:\n', 'italic')
649648
self._text_out.insert('end', f'{wiki}', 'normal')
650649
self._text_out['state'] = tk.DISABLED
650+
return None
651651

652652
def _synonym(self) -> None:
653653
"""
@@ -666,16 +666,16 @@ def _process(word: str):
666666
self._query_thread(key, _process, self._synonym, self._get_word())
667667
syn = self._query_output_pop(key)
668668
if syn is None:
669-
return
670-
if len(syn) == 0:
669+
return None
670+
elif len(syn) == 0:
671671
return self._write(self._cfg.lang('dictionary_no_results'))
672-
self._write(', '.join(syn))
672+
return self._write(', '.join(syn))
673673

674674
def _antonym(self) -> None:
675675
"""
676676
Word aynonym.
677677
"""
678-
key = 'antonym'
678+
key: str = 'antonym'
679679

680680
def _process(word: str):
681681
self._query_output[key] = self._dictionary.antonym(self._lang, word)
@@ -685,10 +685,10 @@ def _process(word: str):
685685
self._query_thread(key, _process, self._antonym, self._get_word())
686686
ant = self._query_output_pop(key)
687687
if ant is None:
688-
return
689-
if len(ant) == 0:
688+
return None
689+
elif len(ant) == 0:
690690
return self._write(self._cfg.lang('dictionary_no_results'))
691-
self._write(', '.join(ant))
691+
return self._write(', '.join(ant))
692692

693693
def _write(self, text: str) -> None:
694694
"""
@@ -727,7 +727,7 @@ def close(self) -> None:
727727
self.root.destroy()
728728

729729

730-
# noinspection PyShadowingNames,PyMissingOrEmptyDocstring
730+
# noinspection PyShadowingNames,PyMissingOrEmptyDocstring,PyTypeChecker
731731
class RichText(tk.Text):
732732
"""
733733
Rich text.
@@ -1191,6 +1191,7 @@ def center_window(root: 'tk.Tk', window_size: Union[Tuple[int, int], List[int]])
11911191
(root.winfo_screenheight() - window_size[1]) / 2))
11921192

11931193

1194+
# noinspection PyTypeChecker
11941195
def make_label_ttk(
11951196
master: Union['tk.Tk', 'tk.Frame'],
11961197
h: int,
@@ -1225,6 +1226,7 @@ def make_label_ttk(
12251226
return labelvar
12261227

12271228

1229+
# noinspection PyTypeChecker
12281230
def make_label(
12291231
master: Union['tk.Tk', 'tk.Frame'],
12301232
h: Union[int, float],

pydetex/_utils_lang.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,14 @@ def get_phrase_from_cursor(s: str, pos_init: int, pos_end: int) -> str:
346346

347347
# Get the first word
348348
s0, i, _ = get_word_from_cursor(s, pos_init)
349-
j = i
349+
# noinspection PyUnusedLocal
350+
j: int = i
350351

351352
if s[pos_end].strip() == '': # Is empty, find the previous word
352353
for k in range(1, pos_end):
353354
_k = pos_end - k
354355
if s[_k].strip() != '':
356+
# noinspection PyUnusedLocal
355357
j = _k + 1
356358
break
357359
else:

pydetex/gui.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class PyDetexGUI(object):
7676
_text_out: 'gui_ut.RichText'
7777
_tokenizer: 'RegexpTokenizer'
7878

79+
# noinspection PyTypeChecker
7980
def __init__(self) -> None:
8081
"""
8182
Constructor.
@@ -309,7 +310,7 @@ def _open_file(self) -> None:
309310
try:
310311
filename_dir = os.path.dirname(filename)
311312
except TypeError: # Linux
312-
return
313+
return None
313314
self._cfg.set(self._cfg.CFG_LAST_OPENED_FOLDER, filename_dir)
314315
try:
315316
text = ut.open_file(filename)
@@ -319,6 +320,7 @@ def _open_file(self) -> None:
319320
os.chdir(filename_dir)
320321
except PermissionError:
321322
pass
323+
return None
322324

323325
def _insert_in(self, text: str, clear: bool = False) -> None:
324326
"""
@@ -457,9 +459,7 @@ def _process_out_key(event: 'tk.Event') -> Optional['tk.Event']:
457459
:param event: Event
458460
:return: Event
459461
"""
460-
# noinspection PyUnresolvedReferences
461-
if event.char == '':
462-
return event
462+
return event if event.char == '' else None
463463

464464
def _detect_language(self) -> None:
465465
"""
@@ -610,7 +610,7 @@ def _process_inner(self) -> None:
610610
self._text_out.insert_highlighted_text(out, True, font_format)
611611

612612
# Final
613-
self._process_final(words)
613+
return self._process_final(words)
614614

615615
def _process_final(self, words: int = 0) -> None:
616616
"""
@@ -646,7 +646,7 @@ def _process_clip(self) -> None:
646646
Process from clipboard. Tries with pooling.
647647
"""
648648
if not self._clip:
649-
return
649+
return None
650650

651651
def _paste():
652652
return pyperclip.paste()
@@ -669,14 +669,14 @@ def _paste():
669669
self._paste_timeout_error = 0
670670
error = f'Paste process failed after {_MAX_PASTE_RETRY} attempts'
671671
warn(error)
672-
return
672+
return None
673673

674674
self._paste_timeout_error = 0
675675
text = text.strip()
676676
if text == '':
677677
return self._status(self._cfg.lang('clip_empty'), True)
678678
self._insert_in(text, True)
679-
self._process()
679+
return self._process()
680680

681681
def _get_pipeline_results(self) -> str:
682682
"""

0 commit comments

Comments
 (0)