laike9m / pdir2

Pretty dir() printing with joy:beer:
MIT License
1.33k stars 47 forks source link

python3.11: add the `__getstate__` dunder #73

Closed supakeen closed 1 year ago

supakeen commented 1 year ago

This patch adds enough support for the testcases to pass on Python 3.11.

I (currently) maintain the Fedora package for pdir2 and wrote this patch when we couldn't build this package in F37. I should've upstreamed it earlier :)

This adds in the __getstate__ method that was breaking the testcases on Python 3.11.

supakeen commented 1 year ago

I don't entirely understand why pdm is being super specific here, it seems to be saying that it can't select numpy (which has a < 3.11 specifier) which can't be resolved with the (now) missing < 3.11 specifier in pyproject.toml.

laike9m commented 1 year ago

I think the [error](https://github.com/laike9m/pdir2/actions/runs/3450344893/jobs/5758883348#:~:text=resolvelib.resolvers.-,ResolutionImpossible,-%3A%20%5BRequirementInformation\(requirement%3DPythonRequirement) happens because numpy 1.12.6 (which is the currently pinned version) is incompatible with the new restriction Python >3.7.1, as it Requires: Python >=3.7, <3.11

Numpy is only needed as a dep of Pandas (which is required by tests), so you should be able to run pdm update to update the numpy's version to be compatible with Python >3.7.1. Or maybe you can manually update its version.

supakeen commented 1 year ago

I think the [error](https://github.com/laike9m/pdir2/actions/runs/3450344893/jobs/5758883348#:~:text=resolvelib.resolvers.-,ResolutionImpossible,-%3A%20%5BRequirementInformation(requirement%3DPythonRequirement) happens because numpy 1.12.6 (which is the currently pinned version) is incompatible with the new restriction Python >3.7.1, as it Requires: Python >=3.7, <3.11

Numpy is only needed as a dep of Pandas (which is required by tests), so you should be able to run pdm update to update the numpy's version to be compatible with Python >3.7.1. Or maybe you can manually update its version.

Seems to be a bit more interesting than that, running this fails to resolve with the following:

Inside an active virtualenv /home/supakeen/dev/src/priv/supakeen/pdir2/venv, reuse it.
🔒 Lock successful
Changes are written to pdm.lock.
See /tmp/pdm-install-resolve-ti28lfef.log for detailed debug log.
[ResolutionImpossible]: [RequirementInformation(requirement=NamedRequirement(name='numpy', marker=<Marker('python_version >= "3.10"')>, extras=set(), specifier=<SpecifierSet('>=1.21.0')>, editable=False, prerelease=False), parent=<Candidate pandas 1.3.5 from unknown>)]
Add '-v' to see the detailed traceback

Which sets numpy to >= 1.21.0 when the Python version is >= 3.10. However, numpy does not support 3.11 yet in any release so it's not resolvable.

Perhaps this PR needs to wait until numpy has support? :)

supakeen commented 1 year ago

Honestly suspicious as 1.23.5 wheels have been released yesterday for numpy, which do have 3.11 support. Let's wait a few days :)

laike9m commented 1 year ago

SG. I think we need a new release of pandas that supports 3.11, as numpy is not a direct dependency

actually, seems it's already supported https://github.com/pandas-dev/pandas/issues/46680

aqeelat commented 1 year ago

@laike9m the package already has __getstate__. Is this PR still needed?

supakeen commented 1 year ago

@aqeelat I think new versions have been released so I'll package those and see if tests fail and do any followup PR as necessary :)

laike9m commented 1 year ago

Yes, the new release supports __getstate__ and fixed the tests