Skip to content

Remove silx.gui.plot._utils.timestamp and future annotations#4630

Merged
loichuder merged 3 commits into
mainfrom
clean-up-py310
Jun 19, 2026
Merged

Remove silx.gui.plot._utils.timestamp and future annotations#4630
loichuder merged 3 commits into
mainfrom
clean-up-py310

Conversation

@loichuder

@loichuder loichuder commented Jun 17, 2026

Copy link
Copy Markdown
Member

PR summary

Fix #4235

There is still some mention to Python 2.7 in very specific code (e.g. EdfFile). To be discussed if we want to remove it.

from __future__ import annotations is actually still needed if the class name is used as a type hint before the class is defined (forward references, present in e.g. colors, PlotWidget). This is because the lazy evaluation of annotations is only implemented in Python 3.14 (https://peps.python.org/pep-0749/), even though the from __future__ import annotations behaviour dates as far as Python 3.7 (https://peps.python.org/pep-0563/).

Instead of keeping from __future__ import annotations in only a few files, I converted the forward references to string annotations (doing explicitely what from __future__ is doing) where needed.

AI Disclosure

  • I chatted with Claude to build an understanding of the need of the from __future__ import annotations

@loichuder loichuder force-pushed the clean-up-py310 branch 2 times, most recently from c917531 to 61ac22d Compare June 18, 2026 09:33
_EPOCH = dt.datetime(1970, 1, 1, tzinfo=dateutil.tz.tzutc())


def timestamp(dtObj):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

timestamp is available on datetime objects since Python 3.3: https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp

"""

def __init__(self, parent: qt.Qwidget | None = None):
def __init__(self, parent: qt.QWidget | None = None):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removing from __future__ import annotations allowed to catch this typo in the type hint

@loichuder loichuder force-pushed the clean-up-py310 branch 2 times, most recently from 922381d to 30ca08d Compare June 19, 2026 11:35
@loichuder loichuder changed the title Clean up py310 Remove silx.gui.plot._utils.timestamp and future annotations Jun 19, 2026
@loichuder loichuder requested a review from a team June 19, 2026 11:36

@t20100 t20100 left a comment

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.

LGTM, thanks for the clean-up

@loichuder loichuder merged commit 678f078 into main Jun 19, 2026
4 checks passed
@loichuder loichuder deleted the clean-up-py310 branch June 19, 2026 13:44
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.

Clean-up code base from code supporting Python<3.10

2 participants