Skip to content

Implement type hints for Environment and environment utilities#4824

Open
Repiteo wants to merge 1 commit intoSCons:masterfrom
Repiteo:type-hints-environment
Open

Implement type hints for Environment and environment utilities#4824
Repiteo wants to merge 1 commit intoSCons:masterfrom
Repiteo:type-hints-environment

Conversation

@Repiteo
Copy link
Contributor

@Repiteo Repiteo commented Feb 2, 2026

Followup to Node type hinting PRs

Hints for Environment are particularly odd, as a lot of cases would technically want to derive from SubstitutionEnvironment instead of Environment.Base. However, I made the type hints act as if Environment.Base is the base class. This is because, in practice, absolutely nobody is using SubstitutionEnvironment, and it might even be refactored away in the future(?). The files adjusted were:

  • SCons/Environment.py
  • SCons/Node/__init__.py (EnvironmentEnvironmentBase)
  • SCons/Node/FS.py (EnvironmentEnvironmentBase)
  • SCons/Script/SConscript.py (Specifically SConsEnvironment and related functions)
  • SCons/Util/envs.py (Utility scripts for environments)

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

@mwichmann
Copy link
Collaborator

Tackling a big one, I see :-) This will take a bit to review - and it seems to have blown up a few tests. In EnvironmentTests, there seem to be two tests (test_ParseConfig and test_ParseFlags) for tuples which need to be preserved as such (when they're the key, value pair of a cpp define), but which have flipped to lists, and one test (test_AppendENVPath) which hasn't kept the expected ordering. Not sure how typing changes can cause that. UtilTests also has some unexpected ordering changes.

@Repiteo
Copy link
Contributor Author

Repiteo commented Feb 3, 2026

Hmm, I might've left a functional change in there while testing return types; it'd explain the tests acting up anyway. Will take a look later

@Repiteo Repiteo force-pushed the type-hints-environment branch 2 times, most recently from fa49a48 to 43f2960 Compare February 3, 2026 15:58
• Hints operate under the assumption that `Environment.Base` is the "base" class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants