-
Notifications
You must be signed in to change notification settings - Fork 5
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 Python 3.9 and make Ruff happy #341
Conversation
Did you mean going through the commits separately? ;-) |
@@ -320,7 +332,8 @@ | |||
"mimetype": "text/x-python", | |||
"name": "python", | |||
"nbconvert_exporter": "python", | |||
"pygments_lexer": "ipython3" | |||
"pygments_lexer": "ipython3", | |||
"version": "3.10.14" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can get ruff
to also strip this version number out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could open an issue to ask them to add this feature.
"r._tool.click(250, 170)" | ||
] | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a new cell here? Is is because of the import? Can we put the import at the top of the cell then? I think it would be best to have a few hidden cells as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because of the import. I did not see that the cells are hidden. Merged them again.
@@ -19,15 +19,13 @@ def _to_floats(x: np.ndarray) -> np.ndarray: | |||
return mdates.date2num(x) if np.issubdtype(x.dtype, np.datetime64) else x | |||
|
|||
|
|||
def _none_if_not_finite(x: Union[float, int, None]) -> Union[float, int, None]: | |||
def _none_if_not_finite(x: float | None) -> float | int | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was int
removed here (and other places)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because int | float
is the same as float
to mypy. This is technically not clean because int
is not a subclass of float
. But mypy treats it as such. And ruff pointed that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But mypy treats it as such
I don't completely understand why we want to make mypy happy when it's asking for something which is not technically correct. Also, it seems weird that the int
was removed from the input type, but not from the return type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't completely understand why we want to make mypy happy when it's asking for something which is not technically correct.
We have to make one of the type checkers happy, otherwise we aren't really testing out the type annotations. The reasoning is given in this PEP https://peps.python.org/pep-0484/#the-numeric-tower. We either open issues upstream or live with the fact float
includes int
with python type hints 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for the tower, but it still doesn't answer why the return type still has float | int
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I can't think of a case where it would make a difference.
Technically, PEP484 only specifies this behaviour for arguments, not return types. But I tried it out with mypy and it seems to behave the same for the return type.
_src_path: https://github.com/scipp/copier_template.git | ||
description: Visualization library for Scipp | ||
max_python: '3.12' | ||
min_python: '3.9' | ||
min_python: '3.10' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you also need to bump the python version for the scipp wheel in the nightly.txt
requirement.
Yes, that might make it easier. But you already looked at it...
Least. It contains largely automated updates of the type hint syntax. |
I don't understand why the docs build fails. It seems like it wants to access |
This would mean it's trying to make a static figure when it should be making an interactive one... nbsphinx_execute_arguments = [
"--Session.metadata=scipp_sphinx_build=True",
] Could it be a change in sphinx that broke this? Alternatively a change in |
The problem only occurs when both matplotlib and ipympl are updated. It seems like But I'm confused about what you said. Should it actually make an interactive figure? The condition is |
According to the So apprently the old command no longer works? Does this mean we have to go and change all our notebooks with interactive plots? :-( |
Allegedly, there is no difference between the two when running in Jupyter: matplotlib/ipympl#529 |
…ave changed in latest version of matplotlib/ipympl
It's weird, when you are in a notebook, and you ask for the backend with In any case, I pushed a fix which seems to work. For context, we were determining if we should make a static or interactive fig based on whether the string |
Thanks, Neil! I was not aware of this piece of code. |
Are you happy with the rest? |
It may be easiest to review by going through the issues separately.
Apply pyupgrade fixes
is the lest important here.