harbor run -t swe-rebench/boxed__mutmut-363harbor download swe-rebench/boxed__mutmut-363Incompatibility with Pydantic model which contains a method For the following minimal example:
from pydantic import BaseModel
class Model(BaseModel):
max_retries: int = 2
def get_max_tries(self) -> int:
return self.max_retries + 1
running mutmut run produces error:
> mutmut run
⠦ Generating mutants
done in 1ms
⠇ Running stats
=========================================================================================================================================================================================================== ERRORS ============================================================================================================================================================================================================
_____________________________________________________________________________________________________________________________________________________________________________________________ ERROR collecting tests/test_main.py _____________________________________________________________________________________________________________________________________________________________________________________________
tests/test_main.py:1: in <module>
from src.main import Model
src/main.py:49: in <module>
class Model(BaseModel):
../.venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py:113: in __new__
private_attributes = inspect_namespace(
../.venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py:506: in inspect_namespace
raise PydanticUserError(
E pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `xǁModelǁget_max_tries__mutmut_mutants = {'xǁModelǁget_max_tries__mutmut_1': <function Model.xǁModelǁget_max_tries__mutmut_1 at 0x1062d4c20>, 'xǁModelǁget_max_tries__mutmut_2': <function Model.xǁModelǁget_max_tries__mutmut_2 at 0x1062d4cc0>}`. All model fields require a type annotation; if `xǁModelǁget_max_tries__mutmut_mutants` is not meant to be a field, you may be able to resolve this error by annotating it as a `ClassVar` or updating `model_config['ignored_types']`.
E
E For further information visit https://errors.pydantic.dev/2.10/u/model-field-missing-annotation
=================================================================================================================================================================================================== short test summary info ===================================================================================================================================================================================================
ERROR tests/test_main.py - pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `xǁModelǁget_max_tries__mutmut_mutants = {'xǁModelǁget_max_tries__mutmut_1': <function Model.xǁModelǁget_max_tries__mutmut_1 at 0x1062d4c20>, 'xǁModelǁget_max_tries__mutmut_2': <function Model.xǁModelǁget_max_tries__mutmut_2 at 0x1062d4cc0>}`. All model fields require a type annotation; if `xǁModelǁget_max_tr...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1 error in 0.13s
failed to collect stats. runner returned 2
The content of mutants/src/main.py:
from inspect import signature as _mutmut_signature
def _mutmut_trampoline(orig, mutants, *args, **kwargs):
import os
mutant_under_test = os.environ['MUTANT_UNDER_TEST']
if mutant_under_test == 'fail':
from mutmut.__main__ import MutmutProgrammaticFailException
raise MutmutProgrammaticFailException('Failed programmatically')
elif mutant_under_test == 'stats':
from mutmut.__main__ import record_trampoline_hit
record_trampoline_hit(orig.__module__ + '.' + orig.__name__)
result = orig(*args, **kwargs)
return result # for the yield case
prefix = orig.__module__ + '.' + orig.__name__ + '__mutmut_'
if not mutant_under_test.startswith(prefix):
result = orig(*args, **kwargs)
return result # for the yield case
mutant_name = mutant_under_test.rpartition('.')[-1]
result = mutants[mutant_name](*args, **kwargs)
return result
from inspect import signature as _mutmut_signature
def _mutmut_yield_from_trampoline(orig, mutants, *args, **kwargs):
import os
mutant_under_test = os.environ['MUTANT_UNDER_TEST']
if mutant_under_test == 'fail':
from mutmut.__main__ import MutmutProgrammaticFailException
raise MutmutProgrammaticFailException('Failed programmatically')
elif mutant_under_test == 'stats':
from mutmut.__main__ import record_trampoline_hit
record_trampoline_hit(orig.__module__ + '.' + orig.__name__)
result = yield from orig(*args, **kwargs)
return result # for the yield case
prefix = orig.__module__ + '.' + orig.__name__ + '__mutmut_'
if not mutant_under_test.startswith(prefix):
result = yield from orig(*args, **kwargs)
return result # for the yield case
mutant_name = mutant_under_test.rpartition('.')[-1]
result = yield from mutants[mutant_name](*args, **kwargs)
return result
from pydantic import BaseModel
class Model(BaseModel):
max_retries: int = 2
def xǁModelǁget_max_tries__mutmut_orig(self) -> int:
return self.max_retries + 1
def xǁModelǁget_max_tries__mutmut_1(self) -> int:
return self.max_retries - 1
def xǁModelǁget_max_tries__mutmut_2(self) -> int:
return self.max_retries + 2
xǁModelǁget_max_tries__mutmut_mutants = {
'xǁModelǁget_max_tries__mutmut_1': xǁModelǁget_max_tries__mutmut_1,
'xǁModelǁget_max_tries__mutmut_2': xǁModelǁget_max_tries__mutmut_2
}
def get_max_tries(self, *args, **kwargs):
result = _mutmut_trampoline(object.__getattribute__(self, "xǁModelǁget_max_tries__mutmut_orig"), object.__getattribute__(self, "xǁModelǁget_max_tries__mutmut_mutants"), *args, **kwargs)
return result
get_max_tries.__signature__ = _mutmut_signature(xǁModelǁget_max_tries__mutmut_orig)
xǁModelǁget_max_tries__mutmut_orig.__name__ = 'xǁModelǁget_max_tries'
is this something that is going to be fixed?