<commit_before>from numba.core.types.abstract import Callable, Literal, Type, Hashable
from numba.core.types.common import (Dummy, IterableType, Opaque,
                                     SimpleIteratorType)
from numba.core.typeconv import Conversion
from numba.core.errors import TypingError, LiteralTypingError


class PyObject(Dummy):
    """
    A generic CPython object.
    """

    def is_precise(self):
        return False


class Phantom(Dummy):
    """
    A type that cannot be materialized.  A Phantom cannot be used as
    argument or return type.
    """


class Undefined(Dummy):
    """
    A type that is left imprecise.  This is used as a temporaray placeholder
    during type inference in the hope that the type can be later refined.
    """

    def is_precise(self):
        return False


class RawPointer(Opaque):
    """
    A raw pointer without any specific meaning.
    """


class StringLiteral(Literal, Dummy):

    def can_convert_to(self, typingctx, other):
        if isinstance(other, UnicodeType):
            return Conversion.safe


Literal.ctor_map[str] = StringLiteral


def unliteral(lit_type):
    """
    Get base type from Literal type.
    """
    if hasattr(lit_type, '__unliteral__'):
        return lit_type.__unliteral__()
    return getattr(lit_type, 'literal_type', lit_type)


def literal(value):
    """Returns a Literal instance or raise LiteralTypingError
    """
    ty = type(value)
    if isinstance(value, Literal):
        msg = "the function does not accept a Literal type; got {} ({})"
        raise ValueError(msg.format(value, ty))
    try:
        ctor = Literal.ctor_map[ty]
    except KeyError:
        raise LiteralTypingError("{} cannot be used as a literal".format(ty))
    else:
        return ctor(value)


def maybe_literal(value):
    """Get a Literal type for the value or None.
    """
    try:
        return literal(value)
    except LiteralTypingError:
        return


class Omitted(Opaque):
    """
    An omitted function argument with a default value.
    """

    def __init__(self, value):
        self._value = value
        # Because id(value) may not match when loading from disk,
        # just return the value if we can hash it.
        # See discussion in gh #6957
        self._value_key = (
            value
            if hasattr(value, "__hash__") and value.__hash__ is not None
            else id(value)
        )
        super(Omitted, self).__init__("omitted(default=%r)" % (value,))

    @property<commit_msg>Added check for undefined type<commit_after>from numba.core.types.abstract import Callable, Literal, Type, Hashable
from numba.core.types.common import (Dummy, IterableType, Opaque,
                                     SimpleIteratorType)
from numba.core.typeconv import Conversion
from numba.core.errors import TypingError, LiteralTypingError
from numba.core.ir import UndefinedType


class PyObject(Dummy):
    """
    A generic CPython object.
    """

    def is_precise(self):
        return False


class Phantom(Dummy):
    """
    A type that cannot be materialized.  A Phantom cannot be used as
    argument or return type.
    """


class Undefined(Dummy):
    """
    A type that is left imprecise.  This is used as a temporaray placeholder
    during type inference in the hope that the type can be later refined.
    """

    def is_precise(self):
        return False


class RawPointer(Opaque):
    """
    A raw pointer without any specific meaning.
    """


class StringLiteral(Literal, Dummy):

    def can_convert_to(self, typingctx, other):
        if isinstance(other, UnicodeType):
            return Conversion.safe


Literal.ctor_map[str] = StringLiteral


def unliteral(lit_type):
    """
    Get base type from Literal type.
    """
    if hasattr(lit_type, '__unliteral__'):
        return lit_type.__unliteral__()
    return getattr(lit_type, 'literal_type', lit_type)


def literal(value):
    """Returns a Literal instance or raise LiteralTypingError
    """
    ty = type(value)
    if isinstance(value, Literal):
        msg = "the function does not accept a Literal type; got {} ({})"
        raise ValueError(msg.format(value, ty))
    try:
        ctor = Literal.ctor_map[ty]
    except KeyError:
        raise LiteralTypingError("{} cannot be used as a literal".format(ty))
    else:
        return ctor(value)


def maybe_literal(value):
    """Get a Literal type for the value or None.
    """
    try:
        return literal(value)
    except LiteralTypingError:
        return


class Omitted(Opaque):
    """
    An omitted function argument with a default value.
    """

    def __init__(self, value):
        self._value = value
        # Because id(value) may not match when loading from disk,
        # just return the value if we can hash it.
        # See discussion in gh #6957
        self._value_key = (
            value
            if not isinstance(value, UndefinedType) and hasattr(value, "__hash__") and value.__hash__ is not None
            else id(value)
        )
        super(Omitted, self).__init__("omitted(default=%r)" % (value,))

    @property
{'fraction_non_alphanumeric': 0.09074941451990633, 'fraction_numerical': 0.00156128024980484, 'mean_word_length': 2.6116983791402397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7625694', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1474, 'n_words': 491}