[PATCH v2] binman: Fix typing for python >= 3.5

Yannic Moog Y.Moog at phytec.de
Mon Jul 14 14:38:43 CEST 2025


Am Montag, dem 14.07.2025 um 07:02 -0500 schrieb Bryan Brattlof:
> On July 14, 2025 thus sayeth Yannic Moog:
> > To make it work with python 3.5 and 3.6, need type hints from the
> > typing module.
> > 
> > Reported-by: Tim Harvey <tharvey at gateworks.com>
> > Fixes: 21bc3433a43d ("binman: rework dropping absent entries from packaged
> > image")
> > Signed-off-by: Yannic Moog <y.moog at phytec.de>
> > ---
> > Changes in v2:
> > - drop newline changes
> > - Link to v1:
> > https://lore.kernel.org/r/20250711-binman-typing-fix-v1-1-66ab075015ac@phytec.de
> > ---
> >  tools/binman/etype/cbfs.py    | 3 ++-
> >  tools/binman/etype/mkimage.py | 3 ++-
> >  tools/binman/etype/section.py | 3 ++-
> >  3 files changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py
> > index
> > 5879f377231bf94697bea97c3cfc3a2515665b8f..c5e77f3a0df22ff768aa7254e4dd9ecbe6
> > f81684 100644
> > --- a/tools/binman/etype/cbfs.py
> > +++ b/tools/binman/etype/cbfs.py
> > @@ -6,6 +6,7 @@
> >  #
> >  
> >  from collections import OrderedDict
> > +from typing import Dict
> 
> It's been a while from my Python days so I'm still trying to understand 
> what's going on, but my understanding is the 'typing' module is 
> considered deprecated after Python 3.9 with PEP 589[0]

That is correct. Afaik it is supposed to be removed with 3.14. (Source: Fluent
Python 2nd Edition).
Python 3.6 (and 3.5) does not have access to __futures__.annotations, that is
why I asked if we strive for python >= 3.5 support or >= 3.7.

So it seems to me there are two paths:

- remove type annotations again.
- when this typing module gets removed, migrate and require python >= 3.7

What do you think is the best course of action?

Yannic

> 
> It seems like we're asked to use:
> 
>     from __future__ import annotations
> 
> ~Bryan
> 
> [0] https://peps.python.org/pep-0585/


More information about the U-Boot mailing list