Skip to content

Commit d99c5a7

Browse files
committed
docs(lexer[mypy]) Simplify docs extension imports
why: Mypy was flagging the console lexer fallback import path and stale test ignores even though the docs extensions are loaded from docs/_ext on sys.path. what: - replace the console lexer try/except import with the supported top-level import - remove unused import-not-found ignores from the lexer tests - keep lexer behavior unchanged while restoring a clean mypy run
1 parent fa472f7 commit d99c5a7

3 files changed

Lines changed: 3 additions & 16 deletions

File tree

docs/_ext/vcspull_console_lexer.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@
1111
from pygments.lexer import Lexer, do_insertions, line_re # type: ignore[attr-defined]
1212
from pygments.lexers.shell import BashLexer
1313
from pygments.token import Generic, Text
14-
15-
try:
16-
# When running as Sphinx extension (docs/_ext in path)
17-
from vcspull_output_lexer import ( # type: ignore[import-not-found]
18-
VcspullOutputLexer,
19-
)
20-
except ImportError:
21-
# When running via pytest (relative import)
22-
from .vcspull_output_lexer import VcspullOutputLexer
14+
from vcspull_output_lexer import VcspullOutputLexer
2315

2416

2517
class VcspullConsoleLexer(Lexer):

tests/docs/_ext/test_vcspull_console_lexer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
import pytest
88
from pygments.token import Token
9-
from vcspull_console_lexer import ( # type: ignore[import-not-found]
10-
VcspullConsoleLexer,
11-
)
9+
from vcspull_console_lexer import VcspullConsoleLexer
1210

1311
# --- Console session tests ---
1412

tests/docs/_ext/test_vcspull_output_lexer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
import pytest
88
from pygments.token import Token
9-
from vcspull_output_lexer import ( # type: ignore[import-not-found]
10-
VcspullOutputLexer,
11-
tokenize_output,
12-
)
9+
from vcspull_output_lexer import VcspullOutputLexer, tokenize_output
1310

1411
# --- List output tests ---
1512

0 commit comments

Comments
 (0)