Skip to content

Commit 0035fb0

Browse files
committed
remove timer
1 parent 165d9f2 commit 0035fb0

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

rich/_timer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from time import time
2+
3+
import contextlib
4+
5+
6+
@contextlib.contextmanager
7+
def timer(subject: str = "time"): # pragma: no cover
8+
"""print the elapsed time. (only used in debugging)"""
9+
start = time()
10+
yield
11+
elapsed = time() - start
12+
elapsed_ms = elapsed * 1000
13+
print(f"{subject} elapsed {elapsed_ms:.1f}ms")

rich/syntax.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
from .jupyter import JupyterMixin
2828
from .measure import Measurement
2929
from .style import Style
30-
from .text import Span, Text
31-
from ._timer import timer
30+
from .text import Text
3231

3332
TokenType = Tuple[str, ...]
3433

@@ -670,5 +669,4 @@ def __rich_console__(
670669
background_color=args.background_color,
671670
indent_guides=args.indent_guides,
672671
)
673-
with timer():
674-
console.print(syntax, soft_wrap=args.soft_wrap)
672+
console.print(syntax, soft_wrap=args.soft_wrap)

rich/traceback.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,12 @@
1010
from typing import Callable, Dict, Iterable, List, Optional, Type
1111

1212
from pygments.lexers import guess_lexer_for_filename
13-
from pygments.token import (
14-
Comment,
15-
Keyword,
16-
Name,
17-
Number,
18-
Operator,
19-
String,
20-
Token,
21-
Text as TextToken,
22-
)
13+
from pygments.token import Comment, Keyword, Name, Number, Operator, String
14+
from pygments.token import Text as TextToken
15+
from pygments.token import Token
2316

2417
from . import pretty
2518
from ._loop import loop_first, loop_last
26-
from ._timer import timer
2719
from .columns import Columns
2820
from .console import (
2921
Console,

0 commit comments

Comments
 (0)