Skip to content

Commit 54b2b2b

Browse files
authored
cache pygments load (#96)
* cache pygments load * fix cache import * linting * replace "nocover"
1 parent 67a74cd commit 54b2b2b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

devtools/prettier.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
from .utils import DataClassType, LaxMapping, SQLAlchemyClassType, env_true, isatty
77

8+
try:
9+
from functools import cache
10+
except ImportError:
11+
from functools import lru_cache
12+
13+
cache = lru_cache()
14+
815
__all__ = 'PrettyFormat', 'pformat', 'pprint'
916
MYPY = False
1017
if MYPY:
@@ -28,6 +35,7 @@ class SkipPretty(Exception):
2835
pass
2936

3037

38+
@cache
3139
def get_pygments():
3240
try:
3341
import pygments

0 commit comments

Comments
 (0)