lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
760 stars 443 forks source link

Python version deprecation tracking #677

Open MarkZH opened 1 year ago

MarkZH commented 1 year ago

This issue is for discussing the scheduling and motivations for deprecating old Python versions.

Deprecating 3.8 (May 1, 2023)

Deprecating 3.9 (Oct. 2025)

Deprecating 3.10 (Oct. 2026)

Deprecating 3.11 (Oct. 2027)

Deprecating 3.12 (Oct. 2028)

Deprecating 3.13 (Oct. 2029)

AttackingOrDefending commented 1 year ago

With deprecating 3.8, we can use list[dict[str, int]] instead of List[Dict[str, int]], so we can remove from typing import List. With deprecating 3.9, we can use int | str instaed of Union[int, str], and int | None instead of Optional[int].

MarkZH commented 1 year ago

With respect to time.monotonic(), I misinterpreted the Python docs. The documentation states that

Changed in version 3.10: On macOS, the function is now system-wide.

I had thought this meant that the function wasn't guaranteed to be available on macOS. However, according to this cpython issue, the definition of "system-wide" is

[...] the clock is the same for all processes on the system and the reference point does not change after start-up time.

Meaning, time.monotonic() is available for macOS, but the timers on different processes cannot be used together until 3.10. Since all of the timers used in lichess-bot never leave their originating thread or process, this limitation is irrelevant.

However, time.monotonic() has much lower time resolution than time.perf_counter(), so the issue is moot and perf_counter() is a better choice for timing purposes.

AttackingOrDefending commented 5 months ago

With deprecating 3.9 we can use TypeAlias, so we would change MOVE = Union[PlayResult, list[Move]] to MOVE: TypeAlias = Union[PlayResult, list[Move]].

With deprecating 3.10 we can use NotRequired and Required in TypedDicts.

With deprecating 3.11 we can use type instead of TypeAlias, so we would change MOVE: TypeAlias = Union[PlayResult, list[Move]] to type MOVE = Union[PlayResult, list[Move]]. We could also change nested f-strings to only use double quotes (see here).

MarkZH commented 1 month ago

@AttackingOrDefending Since Python 3.9 is a little more than a year away from end-of-life, should we deprecate it soon (with, say, 3 months warning) or wait until it reaches end-of-life?

AttackingOrDefending commented 1 month ago

I think we should wait until it reaches end-of-life, since there are probably people still using python 3.9.

AttackingOrDefending commented 3 weeks ago

With python 3.13 (deprecating 3.12), we can use ReadOnly in TypedDict and also possibly support iOS and android. With python 3.14 (deprecating 3.13), we can remove some (possibly all) from __future__ import annotations statements.