<commit_before>from strawberry_forms.mutations import FormMutation

from .forms import LoginForm, RegisterForm, UpdateUserForm
from .types import MeUser


class Login(FormMutation):
    @classmethod
    def transform(cls, result):
        return MeUser(
            id=result.id,
            email=result.email,
            first_name=result.first_name,
            last_name=result.last_name,
            gender=result.gender,
            open_to_recruiting=result.open_to_recruiting,
            date_birth=result.date_birth,
            business_name=result.business_name,
            fiscal_code=result.fiscal_code,
            vat_number=result.vat_number,
            recipient_code=result.recipient_code,
            pec_address=result.pec_address,
            address=result.address,
            country=result.country,
            phone_number=result.phone_number,
        )

    class Meta:
        form_class = LoginForm
        output_types = (MeUser,)


class Register(FormMutation):
    @classmethod
    def transform(cls, result):
        return MeUser(
            id=result.id,
            email=result.email,
            first_name=result.first_name,
            last_name=result.last_name,
            gender=result.gender,
            open_to_recruiting=result.open_to_recruiting,
            date_birth=result.date_birth,
            business_name=result.business_name,
            fiscal_code=result.fiscal_code,
            vat_number=result.vat_number,
            recipient_code=result.recipient_code,
            pec_address=result.pec_address,
            address=result.address,
            country=result.country,
            phone_number=result.phone_number,
        )

    class Meta:
        form_class = RegisterForm
        output_types = (MeUser,)


class Update(FormMutation):
    @classmethod
    def transform(cls, result):
        return MeUser(
            id=result.id,
            email=result.email,
            first_name=result.first_name,
            last_name=result.last_name,
            gender=result.gender,
            open_to_recruiting=result.open_to_recruiting,
            date_birth=result.date_birth,
            business_name=result.business_name,
            fiscal_code=result.fiscal_code,
            vat_number=result.vat_number,
            recipient_code=result.recipient_code,
            pec_address=result.pec_address,
            address=result.address,
            country=result.country,
            phone_number=result.phone_number,
        )
<commit_msg>Refactor User mutation, use inheritance<commit_after>from strawberry_forms.mutations import FormMutation

from .forms import LoginForm, RegisterForm, UpdateUserForm
from .types import MeUser


def get_me_user_type(result):
    return MeUser(
        id=result.id,
        email=result.email,
        first_name=result.first_name,
        last_name=result.last_name,
        gender=result.gender,
        open_to_recruiting=result.open_to_recruiting,
        date_birth=result.date_birth,
        business_name=result.business_name,
        fiscal_code=result.fiscal_code,
        vat_number=result.vat_number,
        recipient_code=result.recipient_code,
        pec_address=result.pec_address,
        address=result.address,
        country=result.country,
        phone_number=result.phone_number,
    )


class BaseUserMutation(FormMutation):
    @classmethod
    def transform(cls, result):
        return get_me_user_type(result)

    class Meta:

        form_class = RegisterForm
        output_types = (MeUser,)


class Login(BaseUserMutation):
    class Meta:
        form_class = LoginForm
        output_types = (MeUser,)


class Register(BaseUserMutation):
    class Meta:
        form_class = RegisterForm
        output_types = (MeUser,)


class Update(BaseUserMutation):
{'fraction_non_alphanumeric': 0.07367593078133193, 'fraction_numerical': 0.0, 'mean_word_length': 2.40017825311943, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4714021', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1089, 'n_words': 164}