<commit_before>from models.items.item_template import ItemTemplateSchema

from database.main import session


def load_item(item_id: int):
    """
    Load an item from item_template, convert it to a object of Class Item and return it
    """
    if item_id <= 0 or item_id is None:
        raise Exception("There is no such item with an ID that's 0 or negative!")

    item_template_info: ItemTemplateSchema = session.query(ItemTemplateSchema).get(item_id)

    return item_template_info.convert_to_item_object()<commit_msg>Improved the error checking in models/items/loader<commit_after>from models.items.item_template import ItemTemplateSchema

from database.main import session


def load_item(item_id: int):
    """
    Load an item from item_template, convert it to a object of Class Item and return it
    """
    if item_id <= 0 or not isinstance(item_id, int):
        raise Exception("There is no such item with an ID that's 0 or negative!")

    item_template_info: ItemTemplateSchema = session.query(ItemTemplateSchema).get(item_id)

    return item_template_info.convert_to_item_object()
{'fraction_non_alphanumeric': 0.07181818181818182, 'fraction_numerical': 0.0036363636363636364, 'mean_word_length': 4.397058823529412, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1513147', 'n_tokens_mistral': 319, 'n_tokens_neox': 305, 'n_words': 108}