Skip to content

Commit 1e0f8d0

Browse files
author
Kareem Zidane
committed
factor out nullcontext
1 parent b4c2095 commit 1e0f8d0

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

check50/__main__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import termcolor
2323

2424
from . import _exceptions, internal, renderer, __version__
25+
from .contextmanagers import nullcontext
2526
from .runner import CheckRunner
2627

2728
LOGGER = logging.getLogger("check50")
@@ -53,13 +54,6 @@ def format(self, record):
5354
return msg if not self.use_color else termcolor.colored(msg, getattr(record, "color", self.COLORS.get(record.levelname)))
5455

5556

56-
@contextlib.contextmanager
57-
def nullcontext(entry_result=None):
58-
"""This is just contextlib.nullcontext but that function is only available in 3.7+."""
59-
yield entry_result
60-
61-
62-
6357
_exceptions.ExceptHook.initialize()
6458

6559

check50/_exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import lib50
66
import termcolor
77

8-
from contextlib import nullcontext
9-
108
from . import internal, __version__
9+
from .contextmanagers import nullcontext
1110

1211
class Error(Exception):
1312
"""Exception for internal check50 errors."""

check50/contextmanagers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import contextlib
2+
3+
4+
@contextlib.contextmanager
5+
def nullcontext(entry_result=None):
6+
"""This is just contextlib.nullcontext but that function is only available in 3.7+."""
7+
yield entry_result

0 commit comments

Comments
 (0)