Skip to content

Do not compile SConscripts with the future flags of SCons modules - #4924

Merged
bdbaddog merged 1 commit into
SCons:masterfrom
adamsthws:fix/sconscript-future-flags
Oct 16, 2026
Merged

bdbaddog merged 1 commit into
SCons:masterfrom
adamsthws:fix/sconscript-future-flags

Conversation

@adamsthws

Copy link
Copy Markdown
Contributor

SCons 4.11 added from __future__ import annotations to SConscript.py, Main.py and Variables/__init__.py. The compile()/exec() calls there that run SConscripts, site_init.py and variables files inherit that flag, so annotations in user scripts became strings. Among other things, dataclasses then no longer recognises InitVar fields, which broke LibreTiny builds under PlatformIO 6.2.0:

TypeError: Library.__post_init__() missing 1 required positional argument: 'env':

This passes dont_inherit=True at those call sites (including -f -). Variables files now also get their own filename in tracebacks instead of <string>.

New test test/SConscript/future-flags.py fails on master and passes with this change.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation
    (not applicable: no documented behaviour changes)

...

SConscript.py, Main.py and Variables/__init__.py use
"from __future__ import annotations", and the compile()/exec() calls
that run SConscripts, site_init.py and variables files inherited it.
Annotations in those files became strings, which stopped dataclasses
from recognising InitVar fields. Pass dont_inherit=True.

Signed-off-by: Adam Matthews <52178922+adamsthws@users.noreply.github.com>
@adamsthws

Copy link
Copy Markdown
Contributor Author

For context, this was found while testing fixes for Sonoff-OTA, an over-the-air Sonoff S60 to Tasmota converter. The related pull requests in other projects, and how each was tested, are collected in docs/upstream-contributions.md.

@mwichmann

Copy link
Copy Markdown
Collaborator

That's a nice catch - sorry we broke you :-)

@bdbaddog
bdbaddog merged commit 5087fc0 into SCons:master Oct 16, 2026
11 of 12 checks passed
@mwichmann mwichmann added this to the NextRelease milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants