Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop support for python=3.9 #8937

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

keewis
Copy link
Collaborator

@keewis keewis commented Apr 13, 2024

According to our policy (and NEP-29) we can drop support for python=3.9 since about a week ago. Interestingly, SPEC0 says we could have started doing this about half a year ago (Q4 2023).

We could delay this until we have a release that is compatible with numpy>=2.0, though (numpy>=2.1 will drop support for python=3.9).

  • User visible changes (including notable bug fixes) are documented in whats-new.rst

Comment on lines 131 to 134
# We require a "hack" to tell type checkers that e.g. Variable + DataArray = DataArray
# In reality this returns NotImplementes, but this is not a valid type in python 3.9.
# In reality this returns NotImplemented, but this is not a valid type in python 3.9.
# Therefore, we return DataArray. In reality this would call DataArray.__add__(Variable)
# TODO: change once python 3.10 is the minimum.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@headtr1ck, can you explain (or directly push a fix, if possible) what you meant by this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if I will be able to code anytime soon, so here an explanation first:

If you do operators, python checks the left obj First. Since DataArray is an array-like (and therefore part of VariableCompatible), the type checker thinks that Variable + DataArray = Variable, which is incorrect.
If you want to follow the runtime behavior, you should return NotImplemented, unfortunately it is not a valid type in Python 3.9. Therefore we return DataArray directly.

Now the "fix" would be to change the return type to NotImplemented and check if it works in Python >=3.10 (I have not actually confirmed that, in case just leave things like they are since it is technically working).

@TomNicholas
Copy link
Contributor

This means we could replace Union[] with | everywhere in the type hints right?

@headtr1ck
Copy link
Collaborator

This means we could replace Union[] with | everywhere in the type hints right?

Shouldn't pyupgrade / ruff do that for us?

@keewis
Copy link
Collaborator Author

keewis commented Apr 15, 2024

it does, but only parts of it (other fixes it deems unsafe so they require manual intervention). I don't have time to go through each of them this week, but feel to push any of these directly to this PR.

basnijholt added a commit to pipefunc/pipefunc that referenced this pull request Jun 2, 2024
Because of [NEP29](https://numpy.org/neps/nep-0029-deprecation_policy) NumPy only supports ≥3.10 now.

Also, Zarr, NetworkX, and ([soon](pydata/xarray#8937)) Xarray will support only ≥3.10.
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.

None yet

3 participants