Skip to content

Import Callable from collections.abc#474

Closed
gabe-l-hart wants to merge 2 commits intopy4j:masterfrom
gabe-l-hart:patch-1
Closed

Import Callable from collections.abc#474
gabe-l-hart wants to merge 2 commits intopy4j:masterfrom
gabe-l-hart:patch-1

Conversation

@gabe-l-hart
Copy link
Copy Markdown
Contributor

Description

This PR attempts to address #473


from collections import deque, Callable
from collections import deque
from collections.abc import Callable
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The problem was that it breaks Python 2 so I used the deprecated one. Probably we can just remove the usage of Callable, and check if it is a weakref reference.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes perfect sense! Sorry I missed that. I'll to get a python 2 compatible version up tomorrow.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nah, thanks for addressing this issue man.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to the internet, it looks like the builtin callable should be a solution that works for all 2.X and >=3.2. Is that a safe range for py4j at this point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've verified locally on 2.7, 3.9, and 3.10. I've also verified that in 3.10 an ImportError is raised on from collections import Callable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah it broke python 3.10 support. Or we can even just remove the assert for now.

This should be compatible with all 2.X and >= 3.2

CITE: https://bugs.python.org/issue10518
@gabe-l-hart
Copy link
Copy Markdown
Contributor Author

Hmm. GitHub seems to be struggling this morning, but may have resolved. When I pushed up the latest commit to my branch, it doesn't seem to be getting picked up by this PR. I'm going to try closing and reopening

@gabe-l-hart gabe-l-hart reopened this Mar 17, 2022
@HyukjinKwon
Copy link
Copy Markdown
Member

Actually #475 suggested the fix .. let me merge that one and close this one - will add you as a co-author of #475.

Thanks for investigation @gabe-l-hart!

HyukjinKwon pushed a commit that referenced this pull request Mar 17, 2022
Closes #474

Co-authored-by: Gabe Goodhart <ghart@us.ibm.com>
@gabe-l-hart
Copy link
Copy Markdown
Contributor Author

Thanks for getting the fix through!

@gabe-l-hart gabe-l-hart deleted the patch-1 branch March 18, 2022 14:56
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.

2 participants