fix: make update_command.py runnable on Python >= 3.9#26
Merged
Conversation
The script's `boost_entry: os.DirEntry | None = None` used PEP 604 union syntax, which is a runtime expression only on Python 3.10+. Contributors on 3.9 (which the package's python_requires still includes) got `TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'` the moment they ran the script. The `# Use Python 3.10.` comment at the top was clearly added after someone tripped on this. Switch to `typing.Optional[os.DirEntry]` (importing Optional alongside the other stdlib modules) and update the header comment to call out the 3.9-compat constraint. See ai/improvements_2026-05-09.md item #13. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem.
boost_headers/update_command.pyhadboost_entry: os.DirEntry | None = None. PEP 604 union syntax is a runtime expression only on Python 3.10+. The package'spython_requiresis>= 3.9, < 4, so contributors on 3.9 gotTypeError: unsupported operand type(s) for |: 'type' and 'NoneType'the moment they ran the script. The# Use Python 3.10.comment at the top was the symptom; someone clearly tripped on it before.Fix.
boost_headers/update_command.py— importtyping.Optional, switch the annotation toOptional[os.DirEntry], and update the header comment to call out the 3.9-compat constraint.No functional change. AST scan confirms no remaining
X | Nonein annotation context. Full pytest suite 316/316.