No global typing issues in all code (excluding tests)

This commit is contained in:
Kovid Goyal 2020-03-04 08:08:46 +05:30
parent 36eb52424f
commit 8ad62106e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 20 additions and 13 deletions

View File

@ -12,6 +12,7 @@ from functools import partial
from html.entities import html5 from html.entities import html5
from itertools import groupby from itertools import groupby
from operator import itemgetter from operator import itemgetter
from typing import DefaultDict, Dict, Set
from urllib.request import urlopen from urllib.request import urlopen
os.chdir(os.path.dirname(os.path.abspath(__file__))) os.chdir(os.path.dirname(os.path.abspath(__file__)))
@ -42,10 +43,10 @@ def get_data(fname, folder='UCD'):
# Map of class names to set of codepoints in class # Map of class names to set of codepoints in class
class_maps = {} class_maps: Dict[str, Set[int]] = {}
all_symbols = set() all_symbols = set()
name_map = {} name_map = {}
word_search_map = defaultdict(set) word_search_map: DefaultDict[str, Set[int]] = defaultdict(set)
zwj = 0x200d zwj = 0x200d
marks = set(emoji_skin_tone_modifiers) | {zwj} marks = set(emoji_skin_tone_modifiers) | {zwj}
not_assigned = set(range(0, sys.maxunicode)) not_assigned = set(range(0, sys.maxunicode))
@ -110,9 +111,9 @@ def split_two(line):
return chars, rest return chars, rest
all_emoji = set() all_emoji: Set[int] = set()
emoji_categories = {} emoji_categories: Dict[str, Set[int]] = {}
emoji_presentation_bases = set() emoji_presentation_bases: Set[int] = set()
def parse_emoji(): def parse_emoji():
@ -130,7 +131,8 @@ def parse_emoji():
emoji_presentation_bases.add(base) emoji_presentation_bases.add(base)
doublewidth, ambiguous = set(), set() doublewidth: Set[int] = set()
ambiguous: Set[int] = set()
def parse_eaw(): def parse_eaw():

View File

@ -16,6 +16,7 @@ import sys
import tempfile import tempfile
import time import time
from contextlib import suppress from contextlib import suppress
from typing import cast
import requests import requests
@ -25,11 +26,11 @@ docs_dir = os.path.abspath('docs')
publish_dir = os.path.abspath(os.path.join('..', 'kovidgoyal.github.io', 'kitty')) publish_dir = os.path.abspath(os.path.join('..', 'kovidgoyal.github.io', 'kitty'))
with open('kitty/constants.py') as f: with open('kitty/constants.py') as f:
raw = f.read() raw = f.read()
nv = re.search( nv = cast(re.Match, re.search(
r'^version\s+=\s+\((\d+), (\d+), (\d+)\)', raw, flags=re.MULTILINE) r'^version\s+=\s+\((\d+), (\d+), (\d+)\)', raw, flags=re.MULTILINE))
version = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3)) version = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3))
appname = re.search( appname = cast(re.Match, re.search(
r"^appname\s+=\s+'([^']+)'", raw, flags=re.MULTILINE).group(1) r"^appname\s+=\s+'([^']+)'", raw, flags=re.MULTILINE)).group(1)
ALL_ACTIONS = 'man html build tag sdist upload website'.split() ALL_ACTIONS = 'man html build tag sdist upload website'.split()

View File

@ -12,3 +12,6 @@ blank_line_before_nested_class_or_def = True
[isort] [isort]
combine_as_imports = True combine_as_imports = True
multi_line_output = 5 multi_line_output = 5
[mypy]
files = kitty,kittens,glfw/glfw.py,*.py

View File

@ -19,6 +19,7 @@ from functools import partial
from collections import namedtuple from collections import namedtuple
from contextlib import suppress from contextlib import suppress
from pathlib import Path from pathlib import Path
from typing import cast
base = os.path.dirname(os.path.abspath(__file__)) base = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, 'glfw') sys.path.insert(0, 'glfw')
@ -29,13 +30,13 @@ build_dir = 'build'
constants = os.path.join('kitty', 'constants.py') constants = os.path.join('kitty', 'constants.py')
with open(constants, 'rb') as f: with open(constants, 'rb') as f:
constants = f.read().decode('utf-8') constants = f.read().decode('utf-8')
appname = re.search(r"^appname = '([^']+)'", constants, re.MULTILINE).group(1) appname = cast(re.Match, re.search(r"^appname = '([^']+)'", constants, re.MULTILINE)).group(1)
version = tuple( version = tuple(
map( map(
int, int,
re.search( cast(re.Match, re.search(
r"^version = \((\d+), (\d+), (\d+)\)", constants, re.MULTILINE r"^version = \((\d+), (\d+), (\d+)\)", constants, re.MULTILINE
).group(1, 2, 3) )).group(1, 2, 3)
) )
) )
_plat = sys.platform.lower() _plat = sys.platform.lower()