mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Pygments does not need type checking globally ignored anymore
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -106,7 +106,7 @@ jobs:
|
|||||||
${{ runner.os }}-golang-static-
|
${{ runner.os }}-golang-static-
|
||||||
|
|
||||||
- name: Install build-only deps
|
- 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
|
- name: Run ruff
|
||||||
run: ruff check .
|
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 import nodes
|
||||||
from docutils.parsers.rst.roles import set_classes
|
from docutils.parsers.rst.roles import set_classes
|
||||||
from pygments.lexer import RegexLexer, bygroups # type: ignore
|
from pygments.lexer import RegexLexer
|
||||||
from pygments.token import Comment, Error, Keyword, Literal, Name, Number, String, Whitespace # type: ignore
|
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 import addnodes, version_info
|
||||||
from sphinx.util.logging import getLogger
|
from sphinx.util.logging import getLogger
|
||||||
|
|
||||||
@@ -367,41 +368,45 @@ def replace_string(app: Any, docname: str, source: List[str]) -> None: # {{{
|
|||||||
# config file docs {{{
|
# 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'
|
name = 'Conf'
|
||||||
aliases = ['conf']
|
aliases = ['conf']
|
||||||
filenames = ['*.conf']
|
filenames = ['*.conf']
|
||||||
|
|
||||||
def map_flags(self: RegexLexer, val: str, start_pos: int) -> Iterator[Tuple[int, Any, str]]:
|
def map_flags(self: RegexLexer, val: str, start_pos: int) -> Iterator[Tuple[int, Any, str]]:
|
||||||
expecting_arg = ''
|
expecting_arg = ''
|
||||||
s = Shlex(val)
|
s = Shlex(val)
|
||||||
from kitty.options.utils import allowed_key_map_options
|
from kitty.options.utils import allowed_key_map_options
|
||||||
last_pos = 0
|
last_pos = 0
|
||||||
while (tok := s.next_word())[0] > -1:
|
while (tok := s.next_word())[0] > -1:
|
||||||
x = tok[1]
|
x = tok[1]
|
||||||
if tok[0] > last_pos:
|
if tok[0] > last_pos:
|
||||||
yield start_pos + last_pos, Whitespace, ' ' * (tok[0] - last_pos)
|
yield start_pos + last_pos, Whitespace, ' ' * (tok[0] - last_pos)
|
||||||
last_pos = tok[0] + len(x)
|
last_pos = tok[0] + len(x)
|
||||||
tok_start = start_pos + tok[0]
|
tok_start = start_pos + tok[0]
|
||||||
if expecting_arg:
|
if expecting_arg:
|
||||||
yield tok_start, String, x
|
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 = ''
|
expecting_arg = ''
|
||||||
elif x.startswith('--'):
|
yield tok_start, Name, x
|
||||||
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
|
|
||||||
else:
|
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()
|
start_pos = match.start()
|
||||||
val = match.group()
|
val = match.group()
|
||||||
parts = val.split(maxsplit=1)
|
parts = val.split(maxsplit=1)
|
||||||
@@ -465,7 +470,7 @@ class ConfLexer(RegexLexer): # type: ignore
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SessionLexer(RegexLexer): # type: ignore
|
class SessionLexer(RegexLexer):
|
||||||
name = 'Session'
|
name = 'Session'
|
||||||
aliases = ['session']
|
aliases = ['session']
|
||||||
filenames = ['*.session']
|
filenames = ['*.session']
|
||||||
|
|||||||
Reference in New Issue
Block a user