Skip to content

Commit 4f62b34

Browse files
Lazily import tomlkit in arguments_manager
1 parent 6ec3d9b commit 4f62b34

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Lazily import ``dill`` in ``pylint.lint.parallel`` and ``isort`` in
2-
``pylint.checkers.imports`` so they are only loaded when actually needed.
3-
``dill`` (~13 ms) is now deferred until parallel checking runs, and
4-
``isort`` (~60 ms) until import-ordering messages are checked.
1+
Lazily import ``isort``, ``dill``, ``multiprocessing``/``concurrent.futures``,
2+
and ``tomlkit`` so they are only loaded when actually needed.
3+
This reduces startup time by ~25% (e.g. ``--version``: 91 => 67 ms,
4+
``--help``: 176 => 133 ms, single-file lint: 272 => 226 ms).
55

66
Closes #2866

pylint/config/arguments_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
from collections.abc import Sequence
1515
from typing import TYPE_CHECKING, Any, TextIO
1616

17-
import tomlkit
18-
1917
from pylint import utils
2018
from pylint.config.argument import (
2119
_Argument,
@@ -302,6 +300,8 @@ def _generate_config_file(self, *, minimal: bool = False) -> str:
302300
"""Write a configuration file according to the current configuration into
303301
stdout.
304302
"""
303+
import tomlkit # pylint: disable=import-outside-toplevel
304+
305305
toml_doc = tomlkit.document()
306306
tool_table = tomlkit.table(is_super_table=True)
307307
toml_doc.add(tomlkit.key("tool"), tool_table)

0 commit comments

Comments
 (0)