Skip to content

Conversation

@glemaitre
Copy link
Contributor

closes #572

Python 3.14 implements PEP649 and PEP749. The idea of those is to have a lazy evaluation of the annotation such that the evaluation happen after that the types are defined.

It means that the class __dict__ does not contain anymore the __annotations__ attribute (dict containing the annotations) but instead an __annotate_func__ attribute referring to a function called __annotate__ that when evaluated contains a reference the class __dict__ as mentioned in python/cpython#140820 (comment).

By reading the PEPs, it looks at when unserializing it will recreate the __annotate_func__ attribute.

@ogrisel
Copy link
Contributor

ogrisel commented Oct 31, 2025

Please also document the change in the changelog.

Copy link
Contributor

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @glemaitre!

@ogrisel ogrisel merged commit 6ff1cc2 into cloudpipe:master Oct 31, 2025
25 checks passed
dongjoon-hyun added a commit to apache/spark that referenced this pull request Nov 10, 2025
### What changes were proposed in this pull request?

This PR aims to upgrade `cloudpickle` to 3.1.2.

### Why are the changes needed?

To support Python 3.14 properly.
- https://github.com/cloudpipe/cloudpickle/releases/tag/v3.1.2
- https://github.com/cloudpipe/cloudpickle/blob/master/CHANGES.md#312

    > Fix pickling of abstract base classes containing type annotations for Python 3.14. (cloudpipe/cloudpickle#578)

### Does this PR introduce _any_ user-facing change?

No, Python 3.14 support is not announced yet.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #52964 from dongjoon-hyun/SPARK-54269.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun added a commit to apache/spark that referenced this pull request Nov 10, 2025
### What changes were proposed in this pull request?

This PR aims to upgrade `cloudpickle` to 3.1.2.

### Why are the changes needed?

To support Python 3.14 properly.
- https://github.com/cloudpipe/cloudpickle/releases/tag/v3.1.2
- https://github.com/cloudpipe/cloudpickle/blob/master/CHANGES.md#312

    > Fix pickling of abstract base classes containing type annotations for Python 3.14. (cloudpipe/cloudpickle#578)

### Does this PR introduce _any_ user-facing change?

No, Python 3.14 support is not announced yet.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #52964 from dongjoon-hyun/SPARK-54269.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 9754e17)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 22, 2025
### What changes were proposed in this pull request?

This PR aims to upgrade `cloudpickle` to 3.1.2.

### Why are the changes needed?

To support Python 3.14 properly.
- https://github.com/cloudpipe/cloudpickle/releases/tag/v3.1.2
- https://github.com/cloudpipe/cloudpickle/blob/master/CHANGES.md#312

    > Fix pickling of abstract base classes containing type annotations for Python 3.14. (cloudpipe/cloudpickle#578)

### Does this PR introduce _any_ user-facing change?

No, Python 3.14 support is not announced yet.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#52964 from dongjoon-hyun/SPARK-54269.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
huangxiaopingRD pushed a commit to huangxiaopingRD/spark that referenced this pull request Nov 25, 2025
### What changes were proposed in this pull request?

This PR aims to upgrade `cloudpickle` to 3.1.2.

### Why are the changes needed?

To support Python 3.14 properly.
- https://github.com/cloudpipe/cloudpickle/releases/tag/v3.1.2
- https://github.com/cloudpipe/cloudpickle/blob/master/CHANGES.md#312

    > Fix pickling of abstract base classes containing type annotations for Python 3.14. (cloudpipe/cloudpickle#578)

### Does this PR introduce _any_ user-facing change?

No, Python 3.14 support is not announced yet.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#52964 from dongjoon-hyun/SPARK-54269.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to pickle abstract class (using abc.ABC) with type annotations

2 participants