mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 08:26:56 +00:00
Pygments does not need type checking globally ignored anymore
This commit is contained in:
parent
2d32c1175c
commit
edd466e5f7
2 changed files with 36 additions and 31 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -106,7 +106,7 @@ jobs:
|
|||
${{ runner.os }}-golang-static-
|
||||
|
||||
- name: Install build-only deps
|
||||
run: python -m pip install -r docs/requirements.txt ruff mypy types-requests types-docutils
|
||||
run: python -m pip install -r docs/requirements.txt ruff mypy types-requests types-docutils types-Pygments
|
||||
|
||||
- name: Run ruff
|
||||
run: ruff check .
|
||||
|
|
|
|||
65
docs/conf.py
65
docs/conf.py
|
|
@ -18,8 +18,9 @@ from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple
|
|||
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
from pygments.lexer import RegexLexer, bygroups # type: ignore
|
||||
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, String, Whitespace # type: ignore
|
||||
from pygments.lexer import RegexLexer
|
||||
from pygments.lexer import bygroups as untyped_bygroups
|
||||
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, String, Whitespace
|
||||
from sphinx import addnodes, version_info
|
||||
from sphinx.util.logging import getLogger
|
||||
|
||||
|
|
@ -367,41 +368,45 @@ def replace_string(app: Any, docname: str, source: List[str]) -> None: # {{{
|
|||
# config file docs {{{
|
||||
|
||||
|
||||
class ConfLexer(RegexLexer): # type: ignore
|
||||
def bygroups(*args: Any) -> Any:
|
||||
return untyped_bygroups(*args) # type: ignore[no-untyped-call]
|
||||
|
||||
|
||||
class ConfLexer(RegexLexer):
|
||||
name = 'Conf'
|
||||
aliases = ['conf']
|
||||
filenames = ['*.conf']
|
||||
|
||||
def map_flags(self: RegexLexer, val: str, start_pos: int) -> Iterator[Tuple[int, Any, str]]:
|
||||
expecting_arg = ''
|
||||
s = Shlex(val)
|
||||
from kitty.options.utils import allowed_key_map_options
|
||||
last_pos = 0
|
||||
while (tok := s.next_word())[0] > -1:
|
||||
x = tok[1]
|
||||
if tok[0] > last_pos:
|
||||
yield start_pos + last_pos, Whitespace, ' ' * (tok[0] - last_pos)
|
||||
last_pos = tok[0] + len(x)
|
||||
tok_start = start_pos + tok[0]
|
||||
if expecting_arg:
|
||||
yield tok_start, String, x
|
||||
expecting_arg = ''
|
||||
s = Shlex(val)
|
||||
from kitty.options.utils import allowed_key_map_options
|
||||
last_pos = 0
|
||||
while (tok := s.next_word())[0] > -1:
|
||||
x = tok[1]
|
||||
if tok[0] > last_pos:
|
||||
yield start_pos + last_pos, Whitespace, ' ' * (tok[0] - last_pos)
|
||||
last_pos = tok[0] + len(x)
|
||||
tok_start = start_pos + tok[0]
|
||||
if expecting_arg:
|
||||
yield tok_start, String, x
|
||||
expecting_arg = ''
|
||||
elif x.startswith('--'):
|
||||
expecting_arg = x[2:]
|
||||
k, sep, v = expecting_arg.partition('=')
|
||||
k = k.replace('-', '_')
|
||||
expecting_arg = k
|
||||
if expecting_arg not in allowed_key_map_options:
|
||||
yield tok_start, Error, x
|
||||
elif sep == '=':
|
||||
expecting_arg = ''
|
||||
elif x.startswith('--'):
|
||||
expecting_arg = x[2:]
|
||||
k, sep, v = expecting_arg.partition('=')
|
||||
k = k.replace('-', '_')
|
||||
expecting_arg = k
|
||||
if expecting_arg not in allowed_key_map_options:
|
||||
yield tok_start, Error, x
|
||||
elif sep == '=':
|
||||
expecting_arg = ''
|
||||
yield tok_start, Name, x
|
||||
else:
|
||||
yield tok_start, Name, x
|
||||
yield tok_start, Name, x
|
||||
else:
|
||||
break
|
||||
yield tok_start, Name, x
|
||||
else:
|
||||
break
|
||||
|
||||
def mapargs(self: RegexLexer, match: 're.Match[str]') -> Iterator[Tuple[int, Any, str]]:
|
||||
def mapargs(self: 'ConfLexer', match: 're.Match[str]') -> Iterator[Tuple[int, Any, str]]:
|
||||
start_pos = match.start()
|
||||
val = match.group()
|
||||
parts = val.split(maxsplit=1)
|
||||
|
|
@ -465,7 +470,7 @@ class ConfLexer(RegexLexer): # type: ignore
|
|||
}
|
||||
|
||||
|
||||
class SessionLexer(RegexLexer): # type: ignore
|
||||
class SessionLexer(RegexLexer):
|
||||
name = 'Session'
|
||||
aliases = ['session']
|
||||
filenames = ['*.session']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue