Skip to content

Commit

Permalink
factor out nullcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
Kareem Zidane committed Jun 22, 2021
1 parent b4c2095 commit 1e0f8d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 1 addition & 7 deletions check50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import termcolor

from . import _exceptions, internal, renderer, __version__
from .contextmanagers import nullcontext
from .runner import CheckRunner

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


@contextlib.contextmanager
def nullcontext(entry_result=None):
"""This is just contextlib.nullcontext but that function is only available in 3.7+."""
yield entry_result



_exceptions.ExceptHook.initialize()


Expand Down
3 changes: 1 addition & 2 deletions check50/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import lib50
import termcolor

from contextlib import nullcontext

from . import internal, __version__
from .contextmanagers import nullcontext

class Error(Exception):
"""Exception for internal check50 errors."""
Expand Down
7 changes: 7 additions & 0 deletions check50/contextmanagers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import contextlib


@contextlib.contextmanager
def nullcontext(entry_result=None):
"""This is just contextlib.nullcontext but that function is only available in 3.7+."""
yield entry_result

0 comments on commit 1e0f8d0

Please sign in to comment.