Merge pull request #3399 from JPHutchins/feature/speedup-imports

feat: speedup import time using sys.platform
This commit is contained in:
Will McGugan 2024-07-01 10:37:35 +01:00 committed by GitHub
commit 577def22dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 8 deletions

View File

@ -25,6 +25,7 @@ The following people have contributed to the development of Rich:
- [Kenneth Hoste](https://github.com/boegel)
- [Lanqing Huang](https://github.com/lqhuang)
- [Finn Hughes](https://github.com/finnhughes)
- [JP Hutchins](https://github.com/JPhutchins)
- [Ionite](https://github.com/ionite34)
- [Josh Karpel](https://github.com/JoshKarpel)
- [Jan Katins](https://github.com/jankatins)

View File

@ -1,5 +1,5 @@
import platform
import re
import sys
from colorsys import rgb_to_hls
from enum import IntEnum
from functools import lru_cache
@ -15,7 +15,7 @@ if TYPE_CHECKING: # pragma: no cover
from .text import Text
WINDOWS = platform.system() == "Windows"
WINDOWS = sys.platform == "win32"
class ColorSystem(IntEnum):

View File

@ -1,6 +1,5 @@
import inspect
import os
import platform
import sys
import threading
import zlib
@ -76,7 +75,7 @@ if TYPE_CHECKING:
JUPYTER_DEFAULT_COLUMNS = 115
JUPYTER_DEFAULT_LINES = 100
WINDOWS = platform.system() == "Windows"
WINDOWS = sys.platform == "win32"
HighlighterType = Callable[[Union[str, "Text"]], "Text"]
JustifyMethod = Literal["default", "left", "center", "right", "full"]

View File

@ -1,5 +1,4 @@
import os.path
import platform
import re
import sys
import textwrap
@ -52,7 +51,7 @@ from .text import Text
TokenType = Tuple[str, ...]
WINDOWS = platform.system() == "Windows"
WINDOWS = sys.platform == "win32"
DEFAULT_THEME = "monokai"
# The following styles are based on https://github.com/pygments/pygments/blob/master/pygments/formatters/terminal.py

View File

@ -2,7 +2,6 @@ from __future__ import absolute_import
import linecache
import os
import platform
import sys
from dataclasses import dataclass, field
from traceback import walk_tb
@ -39,7 +38,7 @@ from .syntax import Syntax
from .text import Text
from .theme import Theme
WINDOWS = platform.system() == "Windows"
WINDOWS = sys.platform == "win32"
LOCALS_MAX_LENGTH = 10
LOCALS_MAX_STRING = 80