binman: Fix typing for python >= 3.5
PATCH v2 1/1 binman: Fix typing for python >= 3.5
To make it work with python 3.5 and 3.6, need type hints from the typing module.
---
Changes in v2:
- drop newline changes
- Link to v1: https://lore.kernel.org/r/[email protected]
--- 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(-)
tools/binman/etype/cbfs.py +2 -1
@@ -6,6 +6,7 @@ # from collections import OrderedDict +from typing import Dict from binman import cbfs_util from binman.cbfs_util import CbfsWriter
@@ -276,7 +277,7 @@ class Entry_cbfs(Entry): for entry in self._entries.values(): entry.ListEntries(entries, indent + 1) - def GetEntries(self) -> dict[str, Entry]: + def GetEntries(self) -> Dict[str, Entry]: """Returns the entries (tree children) of this section""" return self._entries
tools/binman/etype/mkimage.py +2 -1
@@ -6,6 +6,7 @@ # from collections import OrderedDict +from typing import Dict from binman.entry import Entry from binman.etype.section import Entry_section
@@ -205,7 +206,7 @@ class Entry_mkimage(Entry_section): self.record_missing_bintool(self.mkimage) return data - def GetEntries(self) -> dict[str, Entry]: + def GetEntries(self) -> Dict[str, Entry]: # Make a copy so we don't change the original entries = OrderedDict(self._entries) if self._imagename:
tools/binman/etype/section.py +2 -1
@@ -12,6 +12,7 @@ from collections import OrderedDict import concurrent.futures import re import sys +from typing import Dict from binman.entry import Entry from binman import state
@@ -537,7 +538,7 @@ class Entry_section(Entry): for entry in self._entries.values(): entry.WriteMap(fd, indent + 1) - def GetEntries(self) -> dict[str, Entry]: + def GetEntries(self) -> Dict[str, Entry]: return self._entries def GetContentsByPhandle(self, phandle, source_entry, required):
---
base-commit: 6bb0679377abb01a82db1ce69b5bf1d40aa02ace
change-id: 20250710-binman-typing-fix-a207bed6416b
Best regards,
Signature · 1 line
Yannic Moog <[email protected]>
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 21 lines
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries from packaged image")Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1: https://lore.kernel.org/r/[email protected]--- 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(-)tools/binman/etype/cbfs.py +0
-0
tools/binman/etype/cbfs.py line 9
Quoted 4 lines
tools/binman/etype/cbfs.py +1
-0@@ -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]
It seems like we're asked to use:
from __future__ import annotations
~Bryan
Am Montag, dem 14.07.2025 um 07:02 -0500 schrieb Bryan Brattlof:
Quoted 19 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 18 lines
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries from packagedimage")
Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
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(-)
Quoted 15 lines
Quoted 11 lines
tools/binman/etype/cbfs.py +0
-0index
5879f377231bf94697bea97c3cfc3a2515665b8f..c5e77f3a0df22ff768aa7254e4dd9ecbe6f81684 100644tools/binman/etype/cbfs.py +0
-0@@ -6,6 +6,7 @@ #
from collections import OrderedDict
+from typing import DictIt'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
Quoted 8 lines
It seems like we're asked to use:
from
__future__import annotations~Bryan
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 41 lines
Am Montag, dem 14.07.2025 um 07:02 -0500 schrieb Bryan Brattlof:
Quoted 19 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 18 lines
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries from packagedimage")
Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
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(-)Quoted 15 lines
Quoted 11 lines
tools/binman/etype/cbfs.py +0
-0index
5879f377231bf94697bea97c3cfc3a2515665b8f..c5e77f3a0df22ff768aa7254e4dd9ecbe6f81684 100644tools/binman/etype/cbfs.py +0
-0@@ -6,6 +6,7 @@ #
from collections import OrderedDict
+from typing import DictIt'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.
Quoted 7 lines
So it seems to me there are two paths:
- remove type annotations again.
- when this typing module gets removed, migrate and require python >= 3.7What do you think is the best course of action?
Grepping around some more it looks like mbedtls is still using the typing module so it's probably fine for now. Though I think 3.14 will be available by October this year and just in time for this next release :/
Going off Python's version status page[0] it looks like we're safe to move the minimum requirement to 3.6 or 3.7. Python 3.5 isn't even listed as end-of-life anymore.
Debian's oldstable (bullseye) seems to be using 3.9[1] Ubuntu's 22.04 (Jammy) seems to use 3.10[2] Yocto's Dunfell is using 3.8[3]
I seem remember Rocky 8 using 3.6 but I can't find a source for that.
It seems like we should look into bumping the minimum version but I tend to refresh my system a little more often so I don't know what pain this would cause others
[0] https://devguide.python.org/versions/
[1] https://wiki.debian.org/Python
[2] https://packages.ubuntu.com/search?keywords=python3
[3] https://github.com/openembedded/openembedded-core/blob/c4fb7d1f0f157ffafd9f907f49ea74b93b2c1d40/meta/recipes-devtools/python/python3_3.8.18.bb#L67
Quoted 10 lines
Yannic
Quoted 8 lines
It seems like we're asked to use:
from
__future__import annotations~Bryan
Quoted 65 lines · Bryan Brattlof
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 41 lines
Am Montag, dem 14.07.2025 um 07:02 -0500 schrieb Bryan Brattlof:
Quoted 19 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 18 lines
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries from packagedimage")
Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
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(-)Quoted 15 lines
Quoted 11 lines
tools/binman/etype/cbfs.py +0
-0index
5879f377231bf94697bea97c3cfc3a2515665b8f..c5e77f3a0df22ff768aa7254e4dd9ecbe6f81684 100644tools/binman/etype/cbfs.py +0
-0@@ -6,6 +6,7 @@ #
from collections import OrderedDict
+from typing import DictIt'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.Quoted 7 lines
So it seems to me there are two paths:
- remove type annotations again.
- when this typing module gets removed, migrate and require python >= 3.7What do you think is the best course of action?
Grepping around some more it looks like mbedtls is still using the typing module so it's probably fine for now. Though I think 3.14 will be available by October this year and just in time for this next release :/
Going off Python's version status page[0] it looks like we're safe to move the minimum requirement to 3.6 or 3.7. Python 3.5 isn't even listed as end-of-life anymore.
Debian's oldstable (bullseye) seems to be using 3.9[1] Ubuntu's 22.04 (Jammy) seems to use 3.10[2] Yocto's Dunfell is using 3.8[3]
I seem remember Rocky 8 using 3.6 but I can't find a source for that.
Quoted 8 lines
It seems like we should look into bumping the minimum version but I tend to refresh my system a little more often so I don't know what pain this would cause others
[0] https://devguide.python.org/versions/
[1] https://wiki.debian.org/Python
[2] https://packages.ubuntu.com/search?keywords=python3
[3] https://github.com/openembedded/openembedded-core/blob/c4fb7d1f0f157ffafd9f907f49ea74b93b2c1d40/meta/recipes-devtools/python/python3_3.8.18.bb#L67
We partly hit this because Ubuntu 20.04 is on, uh, I forget what Tim said now. But I really like to be able to say we work on the oldest still supported common LTS distributions. We may have to bump to 3.7 or newer after v2025.10 so that we don't run in to too many problems with bleeding edge distributions instead.
Signature · 1 line
Tom
Bryan Brattlof
Reviewed-byOn July 14, 2025 thus sayeth Tom Rini:
Quoted 75 lines · Bryan Brattlof
Quoted 65 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 41 lines
Am Montag, dem 14.07.2025 um 07:02 -0500 schrieb Bryan Brattlof:
Quoted 19 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 18 lines
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries from packagedimage")
Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
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(-)Quoted 15 lines
Quoted 11 lines
tools/binman/etype/cbfs.py +0
-0index
5879f377231bf94697bea97c3cfc3a2515665b8f..c5e77f3a0df22ff768aa7254e4dd9ecbe6f81684 100644tools/binman/etype/cbfs.py +0
-0@@ -6,6 +6,7 @@ #
from collections import OrderedDict
+from typing import DictIt'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.Quoted 7 lines
So it seems to me there are two paths:
- remove type annotations again.
- when this typing module gets removed, migrate and require python >= 3.7What do you think is the best course of action?
Grepping around some more it looks like mbedtls is still using the typing module so it's probably fine for now. Though I think 3.14 will be available by October this year and just in time for this next release :/
Going off Python's version status page[0] it looks like we're safe to move the minimum requirement to 3.6 or 3.7. Python 3.5 isn't even listed as end-of-life anymore.
Debian's oldstable (bullseye) seems to be using 3.9[1] Ubuntu's 22.04 (Jammy) seems to use 3.10[2] Yocto's Dunfell is using 3.8[3]
I seem remember Rocky 8 using 3.6 but I can't find a source for that.
Quoted 8 lines
It seems like we should look into bumping the minimum version but I tend to refresh my system a little more often so I don't know what pain this would cause others
[0] https://devguide.python.org/versions/
[1] https://wiki.debian.org/Python
[2] https://packages.ubuntu.com/search?keywords=python3
[3] https://github.com/openembedded/openembedded-core/blob/c4fb7d1f0f157ffafd9f907f49ea74b93b2c1d40/meta/recipes-devtools/python/python3_3.8.18.bb#L67
Quoted 5 lines
We partly hit this because Ubuntu 20.04 is on, uh, I forget what Tim said now. But I really like to be able to say we work on the oldest still supported common LTS distributions. We may have to bump to 3.7 or newer after v2025.10 so that we don't run in to too many problems with bleeding edge distributions instead.
Ah OK yeah that works for me. I wish Python would be a little better with their versions :/
~Bryan
Quoted 75 lines · Tom Rini
Quoted 65 lines · Bryan Brattlof
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 41 lines
Am Montag, dem 14.07.2025 um 07:02 -0500 schrieb Bryan Brattlof:
Quoted 19 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 18 lines
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries from packagedimage")
Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
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(-)Quoted 15 lines
Quoted 11 lines
tools/binman/etype/cbfs.py +0
-0index
5879f377231bf94697bea97c3cfc3a2515665b8f..c5e77f3a0df22ff768aa7254e4dd9ecbe6f81684 100644tools/binman/etype/cbfs.py +0
-0@@ -6,6 +6,7 @@ #
from collections import OrderedDict
+from typing import DictIt'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.Quoted 7 lines
So it seems to me there are two paths:
- remove type annotations again.
- when this typing module gets removed, migrate and require python >= 3.7What do you think is the best course of action?
Grepping around some more it looks like mbedtls is still using the typing module so it's probably fine for now. Though I think 3.14 will be available by October this year and just in time for this next release :/
Going off Python's version status page[0] it looks like we're safe to move the minimum requirement to 3.6 or 3.7. Python 3.5 isn't even listed as end-of-life anymore.
Debian's oldstable (bullseye) seems to be using 3.9[1] Ubuntu's 22.04 (Jammy) seems to use 3.10[2] Yocto's Dunfell is using 3.8[3]
I seem remember Rocky 8 using 3.6 but I can't find a source for that.
Quoted 8 lines
It seems like we should look into bumping the minimum version but I tend to refresh my system a little more often so I don't know what pain this would cause others
[0] https://devguide.python.org/versions/
[1] https://wiki.debian.org/Python
[2] https://packages.ubuntu.com/search?keywords=python3
[3] https://github.com/openembedded/openembedded-core/blob/c4fb7d1f0f157ffafd9f907f49ea74b93b2c1d40/meta/recipes-devtools/python/python3_3.8.18.bb#L67
Quoted 5 lines
We partly hit this because Ubuntu 20.04 is on, uh, I forget what Tim said now. But I really like to be able to say we work on the oldest still supported common LTS distributions. We may have to bump to 3.7 or newer after v2025.10 so that we don't run in to too many problems with bleeding edge distributions instead.
Ah, I should have looked this up as I see:
https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Python3_by_default
This says Ubuntu 20.04 is Python 3.8. Sorry for all the reworking here Yannic. Given the removal of this in 3.14 which will come out in time for us to get bug reports after the release, and also that the oldest LTS still otherwise supported is using Python 3.8, I asked you to support too far back and we should aim for 3.7 or newer in a way that won't cause problems with 3.14 as soon as that comes out.
Signature · 1 line
Tom
Am Montag, dem 14.07.2025 um 11:13 -0600 schrieb Tom Rini:
Quoted 92 lines · Tom Rini
Quoted 82 lines · Bryan Brattlof
Quoted 75 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 46 lines
Am Montag, dem 14.07.2025 um 07:02 -0500 schrieb Bryan Brattlof:
Quoted 29 lines
On July 14, 2025 thus sayeth Yannic Moog:
Quoted 28 lines
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries frompackaged
image")Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
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(-)tools/binman/etype/cbfs.py +0
-0index
5879f377231bf94697bea97c3cfc3a2515665b8f..c5e77f3a0df22ff768aa7254e4dd9ecbe6
f81684 100644tools/binman/etype/cbfs.py +0
-0@@ -6,6 +6,7 @@ #Quoted 8 lines
Quoted 3 lines
from collections import OrderedDict
+from typing import DictIt'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.Quoted 8 lines
So it seems to me there are two paths:
- remove type annotations again.
- when this typing module gets removed, migrate and require python >= 3.7What do you think is the best course of action?
Grepping around some more it looks like mbedtls is still using the typing module so it's probably fine for now. Though I think 3.14 will be available by October this year and just in time for this next release :/
Going off Python's version status page[0] it looks like we're safe to move the minimum requirement to 3.6 or 3.7. Python 3.5 isn't even listed as end-of-life anymore.
Debian's oldstable (bullseye) seems to be using 3.9[1] Ubuntu's 22.04 (Jammy) seems to use 3.10[2] Yocto's Dunfell is using 3.8[3]
I seem remember Rocky 8 using 3.6 but I can't find a source for that.
It seems like we should look into bumping the minimum version but I tend to refresh my system a little more often so I don't know what pain this would cause others
Quoted 5 lines
We partly hit this because Ubuntu 20.04 is on, uh, I forget what Tim said now. But I really like to be able to say we work on the oldest still supported common LTS distributions. We may have to bump to 3.7 or newer after v2025.10 so that we don't run in to too many problems with bleeding edge distributions instead.
Ah, I should have looked this up as I see:
https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Python3_by_default
Quoted 6 lines
This says Ubuntu 20.04 is Python 3.8. Sorry for all the reworking here Yannic. Given the removal of this in 3.14 which will come out in time for us to get bug reports after the release, and also that the oldest LTS still otherwise supported is using Python 3.8, I asked you to support too far back and we should aim for 3.7 or newer in a way that won't cause problems with 3.14 as soon as that comes out.
No worries, Tom. Thanks for clarifying. Will send with __future__ import.
Quoted 85 lines · Yannic Moog
To make it work with python 3.5 and 3.6, need type hints from the typing module.
Reported-by Tim Harvey <[email protected]>Fixes 21bc3433a43d ("binman: rework dropping absent entries from packaged image")Signed-off-by Yannic Moog <[email protected]>---
Changes in v2:
- drop newline changes
- Link to v1: https://lore.kernel.org/r/[email protected]--- 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(-)tools/binman/etype/cbfs.py +2
-1@@ -6,6 +6,7 @@ # from collections import OrderedDict +from typing import Dict from binman import cbfs_util from binman.cbfs_util import CbfsWriter@@ -276,7 +277,7 @@ class Entry_cbfs(Entry): for entry in self._entries.values(): entry.ListEntries(entries, indent + 1) - def GetEntries(self) -> dict[str, Entry]: + def GetEntries(self) -> Dict[str, Entry]: """Returns the entries (tree children) of this section""" return self._entriestools/binman/etype/mkimage.py +2
-1@@ -6,6 +6,7 @@ # from collections import OrderedDict +from typing import Dict from binman.entry import Entry from binman.etype.section import Entry_section@@ -205,7 +206,7 @@ class Entry_mkimage(Entry_section): self.record_missing_bintool(self.mkimage) return data - def GetEntries(self) -> dict[str, Entry]: + def GetEntries(self) -> Dict[str, Entry]: # Make a copy so we don't change the original entries = OrderedDict(self._entries) if self._imagename:tools/binman/etype/section.py +2
-2@@ -12,6 +12,7 @@ from collections import OrderedDict import concurrent.futures import re import sys +from typing import Dict from binman.entry import Entry from binman import state@@ -537,7 +538,7 @@ class Entry_section(Entry): for entry in self._entries.values(): entry.WriteMap(fd, indent + 1) - def GetEntries(self) -> dict[str, Entry]: + def GetEntries(self) -> Dict[str, Entry]: return self._entries def GetContentsByPhandle(self, phandle, source_entry, required): ---base-commit:
6bb0679377abb01a82db1ce69b5bf1d40aa02ace
change-id: 20250710-binman-typing-fix-a207bed6416b
Quoted 4 lines
Best regards,
--
Yannic Moog <[email protected]>
Thanks Yannic,
24.04.6 LTS)
Best Regards,
Tim