1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 21:26:44 +02:00

Add initial typing support

This commit is contained in:
Igor Chubin
2021-01-31 18:35:59 +01:00
parent bda370afaf
commit 5bb899be9e
7 changed files with 54 additions and 17 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ specified by an environment variable is not an integer, it is ignored.
from __future__ import print_function
import os
from pygments.styles import get_all_styles
from pygments.styles import get_all_styles # type: ignore
#def get_all_styles():
# return []
+2 -2
View File
@@ -5,8 +5,8 @@ Will be merged with panela later.
import re
from colorama import Fore, Back, Style
import colored
from colorama import Fore, Back, Style # type: ignore
import colored # type: ignore
PALETTES = {
0: {
+2 -2
View File
@@ -8,8 +8,8 @@ Uses external pygments formatters for highlighting (passed as an argument).
"""
import re
import ansiwrap
import colored
import ansiwrap # type: ignore
import colored # type: ignore
def format_text(text, config=None, highlighter=None):
"""
+3 -3
View File
@@ -26,9 +26,9 @@ import os
import sys
import re
import colored
from pygments import highlight as pygments_highlight
from pygments.formatters import Terminal256Formatter # pylint: disable=no-name-in-module
import colored # type: ignore
from pygments import highlight as pygments_highlight # type: ignore
from pygments.formatters import Terminal256Formatter # type: ignore # pylint: disable=no-name-in-module
# pylint: disable=wrong-import-position
sys.path.append(os.path.abspath(os.path.join(__file__, '..')))
from config import CONFIG
+11 -9
View File
@@ -6,7 +6,9 @@ from the project tree.
"""
import pygments.lexers
from typing import Dict
import pygments.lexers # type: ignore
LEXER = {
"assembly" : pygments.lexers.NasmLexer,
@@ -85,7 +87,7 @@ LEXER = {
}
# canonical names are on the right side
LANGUAGE_ALIAS = {
LANGUAGE_ALIAS: Dict[str, str] = {
'asm' : 'assembly',
'assembler' : 'assembly',
'c++' : 'cpp',
@@ -108,7 +110,7 @@ LANGUAGE_ALIAS = {
'm' : 'octave',
}
VIM_NAME = {
VIM_NAME: Dict[str, str] = {
'assembly' : 'asm',
'bash' : 'sh',
'coffeescript': 'coffee',
@@ -135,7 +137,7 @@ VIM_NAME = {
'flask' : 'python',
}
SO_NAME = {
SO_NAME: Dict[str, str] = {
'coffee' : 'coffeescript',
'js' : 'javascript',
'python3' : 'python-3.x',
@@ -149,10 +151,10 @@ SO_NAME = {
# into canonical cheat.sh names
#
ATOM_FT_NAME = {
ATOM_FT_NAME: Dict[str, str] = {
}
EMACS_FT_NAME = {
EMACS_FT_NAME: Dict[str, str] = {
"asm-mode" : "asm",
"awk-mode" : "awk",
"sh-mode" : "bash",
@@ -217,16 +219,16 @@ EMACS_FT_NAME = {
# vim
}
SUBLIME_FT_NAME = {
SUBLIME_FT_NAME: Dict[str, str] = {
}
VIM_FT_NAME = {
VIM_FT_NAME: Dict[str, str] = {
'asm': 'assembler',
'javascript': 'js',
'octave': 'matlab',
}
VSCODE_FT_NAME = {
VSCODE_FT_NAME: Dict[str, str] = {
}
def rewrite_editor_section_name(section_name):
+1
View File
@@ -15,3 +15,4 @@ pycld2
colorama
pyyaml
python-Levenshtein
pylint
Executable
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
SKIP_FILES=(
lib/adapter/adapter.py
lib/adapter/cmd.py
lib/adapter/latenz.py
lib/adapter/learnxiny.py
lib/adapter/question.py
lib/adapter/internal.py
)
contains_element () {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
_mypy() {
local file
local result=0
# mypy lib/*.py lib/fmt/*.py lib/frontend/*.py
for file in lib/*.py lib/fmt/*.py lib/frontend/*.py lib/adapter/*.py
do
contains_element "$file" "${SKIP_FILES[@]}" && continue
mypy --follow-imports=skip "$file" || result=1
done
return "$result"
}
_mypy