Feb 8, 2024
I have a great general tip for you that simplified my code a bit at no cost.
I have a template that inserts code into new files, and for .py I always add the two following lines:
import dataclasses as dc
import typing as t
Then in later code I can write things like t.List
or dc.dataclass
without adding an import. (ruff will simply remove these imports if I don't use them so it costs me nothing.
(I got import typing as t
from the Python typing special interest group mailing list, I didn't come up with it myself!)