Change semantics of shebang in language configuration - #458
Merged
Conversation
…age python2_with_shebang
pehrsoderman
approved these changes
Aug 13, 2026
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.
Changes the semantics of shebang handling in language detection. When specifying a shebang, one must also specify a pattern (matching a subset or all files matched by files) in which one does shebang detection.
Shebang detection now only applies to language detection. Once a language has been selected, all files matching
filesin that language are included (shebang or not). In particular, this means that if a program has afoo.pywith a python2-shebang and amain.pywithout a shebang, it will now be detected as python2, with two files,foo.pyandmain.py, wheremain.pyis the mainfile. Earlier code would have detected this aspython2_with_shebang, with a single file,foo.py(which would then also end up as the mainfile).Note that our shebang detection is not perfect, and not quite in line with the wording of the spec (which I think requires a shebang in every
.pyfile - Kattis/problem-package-format#591 ). In particular, if you have more.pyfiles without a shebang than you do.pyfiles with a python2-shebang, the language will be detected as python3 (both before and after this PR). Fixing that requires a larger rewrite, which I'm not sure is worth it (as incorrect language detection is extremely likely to be very noticable).Fixes #457