Skip to content

Release backport of fixing field_descriptors to field_specifiers in dataclass_transform for Python 3.6? #74

@bluenote10

Description

@bluenote10

It looks like typing_extension versions <4.2 were contained a small bug related to PEP 681: Within the dataclass_transform decorator, the kwarg field_specifiers was erroneously called field_descriptors. This has recently been fixed for versions 4.2+.

The issue is that versions 4.2+ were not released for Python 3.6. This means that under Python 3.6 the code still looks like this:

if hasattr(typing, 'dataclass_transform'):
    dataclass_transform = typing.dataclass_transform
else:
    def dataclass_transform(
        *,
        eq_default: bool = True,
        order_default: bool = False,
        kw_only_default: bool = False,
        field_descriptors: typing.Tuple[
            typing.Union[typing.Type[typing.Any], typing.Callable[..., typing.Any]],
            ...
        ] = (),
    ) -> typing.Callable[[T], T]:
        ...

This means that it is impossible to use dataclass_transform consistently for across Python 3.6 and later versions (code using the proper keyword field_descriptors crashes at runtime under Python 3.6). Furthermore PEP 681 requires these keywords to be specified statically, so generating the kwargs dynamically doesn't seem to work either.

Would it be possible to backport this fix and release an update of typing_extensions for Python 3.6?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions