--- Begin Message ---
Source: python-marshmallow-dataclass
Version: 8.5.8-3
Severity: serious
Tags: sid bookworm
User: debian...@lists.debian.org
Usertags: needs-update
User: debian-pyt...@lists.debian.org
Usertags: python3.11
Control: affects -1 src:python3-defaults
Dear maintainer(s),
We are in the transition of adding python3.11 as a supported Python
version [0]. With a recent upload of python3-defaults the autopkgtest of
python-marshmallow-dataclass fails in testing when that autopkgtest is
run with the binary packages of python3-defaults from unstable. It
passes when run with only packages from testing. In tabular form:
pass fail
python3-defaults from testing 3.10.6-3
python-marshmallow-dataclass from testing 8.5.8-3
all others from testing from testing
I copied some of the output at the bottom of this report.
Currently this regression is blocking the migration of python3-defaults
to testing [1]. https://docs.python.org/3/whatsnew/3.11.html lists
what's new in Python3.11, it may help to identify what needs to be updated.
More information about this bug and the reason for filing it can be found on
https://wiki.debian.org/ContinuousIntegration/RegressionEmailInformation
Paul
[0] https://bugs.debian.org/1021984
[1] https://qa.debian.org/excuses.php?package=python3-defaults
https://ci.debian.net/data/autopkgtest/testing/amd64/p/python-marshmallow-dataclass/28750374/log.gz
=================================== FAILURES
===================================
_____________ TestClassSchema.test_final_infers_type_from_default
______________
self = <tests.test_class_schema.TestClassSchema
testMethod=test_final_infers_type_from_default>
def test_final_infers_type_from_default(self):
# @dataclasses.dataclass
class A:
data: Final = "a"
# @dataclasses.dataclass
class B:
data: Final = A()
# NOTE: This workaround is needed to avoid a Mypy crash.
# See:
https://github.com/python/mypy/issues/10090#issuecomment-865971891
if not TYPE_CHECKING:
A = dataclasses.dataclass(A)
B = dataclasses.dataclass(B)
tests/test_class_schema.py:242: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.11/dataclasses.py:1220: in dataclass
return wrap(cls)
/usr/lib/python3.11/dataclasses.py:1210: in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
/usr/lib/python3.11/dataclasses.py:958: in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
cls = <class
'tests.test_class_schema.TestClassSchema.test_final_infers_type_from_default.<locals>.B'>
a_name = 'data', a_type = typing.Final, default_kw_only = False
def _get_field(cls, a_name, a_type, default_kw_only):
# Return a Field object for this field name and type.
ClassVars and
# InitVars are also returned, but marked as such (see
f._field_type).
# default_kw_only is the value of kw_only to use if there isn't
a field()
# that defines it.
# If the default value isn't derived from Field, then it's
only a
# normal default value. Convert it to a Field().
default = getattr(cls, a_name, MISSING)
if isinstance(default, Field):
f = default
else:
if isinstance(default, types.MemberDescriptorType):
# This is a field in __slots__, so it has no default value.
default = MISSING
f = field(default=default)
# Only at this point do we know the name and the type. Set
them.
f.name = a_name
f.type = a_type
# Assume it's a normal field until proven otherwise. We're
next
# going to decide if it's a ClassVar or InitVar, everything else
# is just a normal field.
f._field_type = _FIELD
# In addition to checking for actual types here, also check for
# string annotations. get_type_hints() won't always work for us
# (see https://github.com/python/typing/issues/508 for example),
# plus it's expensive and would require an eval for every string
# annotation. So, make a best effort to see if this is a ClassVar
# or InitVar using regex's and checking that the thing referenced
# is actually of the correct type.
# For the complete discussion, see
https://bugs.python.org/issue33453
# If typing has not been imported, then it's impossible for any
# annotation to be a ClassVar. So, only look for ClassVar if
# typing has been imported by any module (not necessarily cls's
# module).
typing = sys.modules.get('typing')
if typing:
if (_is_classvar(a_type, typing)
or (isinstance(f.type, str)
and _is_type(f.type, cls, typing, typing.ClassVar,
_is_classvar))):
f._field_type = _FIELD_CLASSVAR
# If the type is InitVar, or if it's a matching string
annotation,
# then it's an InitVar.
if f._field_type is _FIELD:
# The module we're checking against is the module we're
# currently in (dataclasses.py).
dataclasses = sys.modules[__name__]
if (_is_initvar(a_type, dataclasses)
or (isinstance(f.type, str)
and _is_type(f.type, cls, dataclasses,
dataclasses.InitVar,
_is_initvar))):
f._field_type = _FIELD_INITVAR
# Validations for individual fields. This is delayed until
now,
# instead of in the Field() constructor, since only here do we
# know the field name, which allows for better error reporting.
# Special restrictions for ClassVar and InitVar.
if f._field_type in (_FIELD_CLASSVAR, _FIELD_INITVAR):
if f.default_factory is not MISSING:
raise TypeError(f'field {f.name} cannot have a '
'default factory')
# Should I check for other field settings? default_factory
# seems the most serious to check for. Maybe add others. For
# example, how about init=False (or really,
# init=<not-the-default-init-value>)? It makes no sense for
# ClassVar and InitVar to specify init=<anything>.
# kw_only validation and assignment.
if f._field_type in (_FIELD, _FIELD_INITVAR):
# For real and InitVar fields, if kw_only wasn't specified
use the
# default value.
if f.kw_only is MISSING:
f.kw_only = default_kw_only
else:
# Make sure kw_only isn't set for ClassVars
assert f._field_type is _FIELD_CLASSVAR
if f.kw_only is not MISSING:
raise TypeError(f'field {f.name} is a ClassVar but
specifies '
'kw_only')
# For real fields, disallow mutable defaults. Use
unhashable as a proxy
# indicator for mutability. Read the __hash__ attribute from
the class,
# not the instance.
if f._field_type is _FIELD and f.default.__class__.__hash__ is
None:
raise ValueError(f'mutable default {type(f.default)} for field '
f'{f.name} is not allowed: use
default_factory')
E ValueError: mutable default <class
'tests.test_class_schema.TestClassSchema.test_final_infers_type_from_default.<locals>.A'>
for field data is not allowed: use default_factory
/usr/lib/python3.11/dataclasses.py:815: ValueError
=========================== short test summary info
============================
FAILED
tests/test_class_schema.py::TestClassSchema::test_final_infers_type_from_default
========================= 1 failed, 90 passed in 0.51s
=========================
autopkgtest [23:15:03]: test upstream
OpenPGP_signature
Description: OpenPGP digital signature
--- End Message ---