# Path: coconut/exceptions.py
# class CoconutException(Exception):
#     """Base Coconut exception."""
# 
#     def __init__(self, message, item=None, extra=None):
#         """Creates the Coconut exception."""
#         self.args = (message, item, extra)
# 
#     def message(self, message, item, extra):
#         """Uses arguments to create the message."""
#         if item is not None:
#             message += ": " + ascii(item)
#         if extra is not None:
#             message += " (" + str(extra) + ")"
#         return message
# 
#     def syntax_err(self):
#         """Converts to a SyntaxError."""
#         return SyntaxError(str(self))
# 
#     def __str__(self):
#         """Get the exception message."""
#         return self.message(*self.args)
# 
#     def __reduce__(self):
#         """Get pickling information."""
#         return (self.__class__, self.args)
# 
#     def __repr__(self):
#         """Get a representation of the exception."""
#         return self.__class__.__name__ + "(" + ", ".join(
#             repr(arg) for arg in self.args if arg is not None
#         ) + ")"
# 
# Path: coconut/terminal.py
# def format_error(err_type, err_value, err_trace=None):
# def complain(error):
# def internal_assert(condition, message=None, item=None, extra=None):
# def get_name(expr):
#     def __init__(self, log_to=None, prefix=""):
#     def write(self, s):
#     def writelines(self, lines):
#     def log(self, *args):
#     def logging(self):
#     def __init__(self, other=None):
#     def copy_from(self, other):
#     def reset(self):
#     def copy(self):
#     def display(self, messages, sig="", debug=False, **kwargs):
#     def show(self, *messages):
#     def show_sig(self, *messages):
#     def show_error(self, *messages):
#     def log(self, *messages):
#     def log_func(self, func):
#     def log_prefix(self, prefix, *messages):
#     def log_sig(self, *messages):
#     def log_vars(self, message, variables, rem_vars=("self",)):
#     def get_error(self, err=None, show_tb=None):
#     def in_path(self, new_path, old_path=None):
#     def warn(self, *args, **kwargs):
#     def warn_err(self, warning, force=False):
#     def print_exc(self, err=None, show_tb=None):
#     def log_exc(self, err=None):
#     def log_cmd(self, args):
#     def show_tabulated(self, begin, middle, end):
#     def indent_tracing(self):
#     def print_trace(self, *args):
#     def log_tag(self, tag, code, multiline=False):
#     def log_trace(self, expr, original, loc, item=None, extra=None):
#     def _trace_success_action(self, original, start_loc, end_loc, expr, tokens):
#     def _trace_exc_action(self, original, loc, expr, exc):
#     def trace(self, item):
#     def gather_parsing_stats(self):
#     def patch_logging(self):
#             def getLogger(name=None):
#     def pylog(self, *args, **kwargs):
# class LoggingStringIO(StringIO):
# class Logger(object):


from coconut.root import *  # NOQA
from coconut.exceptions import CoconutException
from coconut.terminal import logger
    from mypy.api import run
import sys
Description: Handles interfacing with MyPy to make --mypy work.
"""

# -----------------------------------------------------------------------------------------------------------------------
# IMPORTS:
# -----------------------------------------------------------------------------------------------------------------------

from __future__ import print_function, absolute_import, unicode_literals, division




try:
except ImportError:
    raise CoconutException(
        "--mypy flag requires MyPy library",
        extra="run '{python} -m pip install coconut[mypy]' to fix".format(python=sys.executable),
    )

# -----------------------------------------------------------------------------------------------------------------------
# CLASSES:
# -----------------------------------------------------------------------------------------------------------------------


def mypy_run(args):
    """Run mypy with given arguments and return the result."""
    logger.log_cmd(["mypy"] + args)
    try:
        stdout, stderr, exit_code = run(args)
    except BaseException:

# Path: coconut/exceptions.py
# class CoconutException(Exception):
#     """Base Coconut exception."""
# 
#     def __init__(self, message, item=None, extra=None):
#         """Creates the Coconut exception."""
#         self.args = (message, item, extra)
# 
#     def message(self, message, item, extra):
#         """Uses arguments to create the message."""
#         if item is not None:
#             message += ": " + ascii(item)
#         if extra is not None:
#             message += " (" + str(extra) + ")"
#         return message
# 
#     def syntax_err(self):
#         """Converts to a SyntaxError."""
#         return SyntaxError(str(self))
# 
#     def __str__(self):
#         """Get the exception message."""
#         return self.message(*self.args)
# 
#     def __reduce__(self):
#         """Get pickling information."""
#         return (self.__class__, self.args)
# 
#     def __repr__(self):
#         """Get a representation of the exception."""
#         return self.__class__.__name__ + "(" + ", ".join(
#             repr(arg) for arg in self.args if arg is not None
#         ) + ")"
# 
# Path: coconut/terminal.py
# def format_error(err_type, err_value, err_trace=None):
# def complain(error):
# def internal_assert(condition, message=None, item=None, extra=None):
# def get_name(expr):
#     def __init__(self, log_to=None, prefix=""):
#     def write(self, s):
#     def writelines(self, lines):
#     def log(self, *args):
#     def logging(self):
#     def __init__(self, other=None):
#     def copy_from(self, other):
#     def reset(self):
#     def copy(self):
#     def display(self, messages, sig="", debug=False, **kwargs):
#     def show(self, *messages):
#     def show_sig(self, *messages):
#     def show_error(self, *messages):
#     def log(self, *messages):
#     def log_func(self, func):
#     def log_prefix(self, prefix, *messages):
#     def log_sig(self, *messages):
#     def log_vars(self, message, variables, rem_vars=("self",)):
#     def get_error(self, err=None, show_tb=None):
#     def in_path(self, new_path, old_path=None):
#     def warn(self, *args, **kwargs):
#     def warn_err(self, warning, force=False):
#     def print_exc(self, err=None, show_tb=None):
#     def log_exc(self, err=None):
#     def log_cmd(self, args):
#     def show_tabulated(self, begin, middle, end):
#     def indent_tracing(self):
#     def print_trace(self, *args):
#     def log_tag(self, tag, code, multiline=False):
#     def log_trace(self, expr, original, loc, item=None, extra=None):
#     def _trace_success_action(self, original, start_loc, end_loc, expr, tokens):
#     def _trace_exc_action(self, original, loc, expr, exc):
#     def trace(self, item):
#     def gather_parsing_stats(self):
#     def patch_logging(self):
#             def getLogger(name=None):
#     def pylog(self, *args, **kwargs):
# class LoggingStringIO(StringIO):
# class Logger(object):


# Path: coconut/command/mypy.py
from coconut.root import *  # NOQA
from coconut.exceptions import CoconutException
from coconut.terminal import logger
    from mypy.api import run
import sys

Description: Handles interfacing with MyPy to make --mypy work.
"""

# -----------------------------------------------------------------------------------------------------------------------
# IMPORTS:
# -----------------------------------------------------------------------------------------------------------------------

from __future__ import print_function, absolute_import, unicode_literals, division




try:
except ImportError:
    raise CoconutException(
        "--mypy flag requires MyPy library",
        extra="run '{python} -m pip install coconut[mypy]' to fix".format(python=sys.executable),
    )

# -----------------------------------------------------------------------------------------------------------------------
# CLASSES:
# -----------------------------------------------------------------------------------------------------------------------


def mypy_run(args):
    """Run mypy with given arguments and return the result."""
    logger.log_cmd(["mypy"] + args)
    try:
        stdout, stderr, exit_code = run(args)
    except BaseException:

        logger.print_exc()