Repository navigation
MNT: Compatibility with Python 3.11 - #13614
Conversation
|
👋 Thank you for your draft pull request! Do you know that you can use |
|
Good to try, though scipy is not installing, so I guess this needs a bit more time!? |
|
Ok, after building scipy from source I have got actual errors in our test suite that are presumably down to Python 3.11: So that's errors in coordinates @eteq @adrn @eerovaher, time @mhvk @taldcroft, cosmology @astropy/cosmology and table |
astropy/coordinates/tests/test_pickle.pyhttps://docs.python.org/3.11/library/pickle.html#object.getstate Changed in version 3.11: Added the default implementation of the cosmologyMaybe just a matter of changing the expected error message for Python 3.11? Or maybe this is a symptom of something else, not sure. table/tests/test_pprint.pyLooks like astropy/time/tests/test_mask.pyThe error message changed. Maybe same problem as |
@pllim. That appears to be the case. |
|
I am very happy for people to push to this PR if we want to use it as the place to address all these issues. |
|
@nstarman - if you have a chance to fix the |
No, seems to be all: python/cpython#31311 So in principle they could be all dealt with by defining a custom _no_setter error string depending on |
So previously astropy/astropy/tests/helper.py Line 412 in 5b6619a was simply falling back to a.__dict__.Should it check now if a is a class, rather than an instance thereof (how?) and then call either a().__getstate__() or a.__getstate__(a)?
|
|
See #13637 for discussion of the |
|
Not sure what is going on. I don't see the Python 3.11 job run after merging Nathan's fix. |
|
Hello @Cadair 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style. There are no PEP8 style issues with this pull request - thanks! 🎉 Comment last updated at 2022-09-13 14:14:26 UTC |
|
Less failures now.
So, the remaining compatibility issue we need to figure out is the |
|
It looks like the coordinates failure actually comes from calling astropy/astropy/tests/helper.py Line 412 in f3ce7b2 I don't have time to look at this today but that is where I would start. |
Yes, see #13614 (comment). |
https://docs.python.org/3.8/library/inspect.html#inspect.isclass ? Is this what you mean? |
Yes, thanks! As there is no general info on the correct initialisation signature for |
|
I just rebased this to clear up the history. More pushes or PRs to main are welcome. |
| if hasattr(a, '__getstate__'): | ||
| dict_a = a.__getstate__(a) if inspect.isclass(a) else a.__getstate__() | ||
| else: | ||
| dict_a = a.__dict__ |
There was a problem hiding this comment.
It would be good to add a comment here to clarify that the hasattr check is only needed for Python < 3.11.
There was a problem hiding this comment.
For class inputs. I don't know if the function might ever be called with some other a input that does not implement __getstate__. Could use some comment though – in theory I guess this could also be called in Python < 3.11 for some class defining their own custom __getstate__.
There was a problem hiding this comment.
If Python 3.11 implemented __getstate__() in object then hasattr(a, "__getstate__") will be true for any a. The check is therefore only needed until 3.11 is the minimum supported Python version. A comment would record that it's safe to simplify once support for older versions of Python is dropped.
There was a problem hiding this comment.
some class defining their own custom
__getstate__
Though obviously defining one without parameters would break stuff in 3.11+...
There was a problem hiding this comment.
OK, I misremembered, thought it was only implemented for class.
But in that case it is certainly more likely to get an a with a different __getstate__ signature – e.g. in the original example, astropy.coordinates.builtin_frames.ICRS.__getstate__ has one required argument, while astropy.coordinates.builtin_frames.ICRS().__getstate__ takes no arguments.
There was a problem hiding this comment.
You mean for using some auto-refactoring tool?
There was a problem hiding this comment.
Well, grep should find the comment as well; humans might not ;-)
There was a problem hiding this comment.
Oh, well, if we do it Eero's way, the code will actually error when we remove that flag from compat, so maybe that is better.
There was a problem hiding this comment.
I pushed a commit that would hopefully settle this debate once and for all.
|
This must be a new one for scipy-dev Just as a note for the final setup: this is obviously not Python 3.11 with minimal dependencies using |
|
Yeah it definitely isn't, I was just merrily hacking away at the CI to get it down to one job. |
Co-authored-by: Derek Homeier <dhomeie@gwdg.de>
|
I tired to group the commits into the changes, hopefully the commits all make sense by themselves now. |
pllim
left a comment
There was a problem hiding this comment.
LGTM! What a beautiful collaboration. Thank you, everyone!
Stuart, thanks for getting rid of my "ooops" commit message. 😆
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
Of course... autobackport would be too easy... |
|
I will do the manual backports, FYI. |
Merge pull request astropy#13614 from Cadair/311_testing MNT: Compatibility with Python 3.11 (cherry picked from commit 616f382)
Merge pull request astropy#13614 from Cadair/311_testing MNT: Compatibility with Python 3.11 (cherry picked from commit 616f382)
| devdeps,mpldev: git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib | ||
| devdeps: scipy>=0.0.dev0 | ||
| devdeps: numpy>=0.0.dev0 | ||
| devdeps,mpldev: matplotlib>=0.0.dev0 |
There was a problem hiding this comment.
@Cadair , this picked up matplotlib 3.6.0rc2 , not a dev version. Is this supposed to happen?
There was a problem hiding this comment.
https://github.com/astropy/astropy/actions/runs/3053254195/jobs/4923644273 (the job on main after merging this)
…5.1.x Backport PR #13614 on branch v5.1.x (MNT: Compatibility with Python 3.11)
Merge pull request astropy#13614 from Cadair/311_testing MNT: Compatibility with Python 3.11 (cherry picked from commit 616f382)
…5.0.x Backport PR #13614 on branch v5.0.x (MNT: Compatibility with Python 3.11)
|
Does anyone know what the |
|
The test header should say. This is from the last successful run on |
|
Thanks! Looked too high up, which was apparently still the header from |
Fix #13522
Fix #13224