Skip to content

Python files have shebangs unnecessarily

Summary

Almost all .py files in the project include shebang lines. Having that line in a .py file that's not meant to be run standalone, can be misleading. First time reviewers might look for a if __name__ == '__main__' line, etc.

Steps to reproduce

git clone https://gitlab.com/BuildStream/buildstream.git && cd buildstream
# To see which ones don't have shebang:
diff <(git grep -l -F '#!/usr/bin/env python3' buildstream | sort) <(find buildstream -name '*.py' | sort)

# To see the ones with the line
git grep -l -F '#!/usr/bin/env python3' buildstream

What is the current bug behavior?

We have lots of files in the output of git grep -l -F '#!/usr/bin/env python3' buildstream

What is the expected correct behavior?

git grep -l -F '#!/usr/bin/env python3' buildstream should return an empty output.

Relevant logs and/or screenshots

diff <(git grep -l -F '#!/usr/bin/env python3' buildstream | sort) <(find buildstream -name '*.py' | sort)
> 4a5
buildstream/_artifactcache/pushreceive.py
> 11a13
buildstream/_frontend/cli.py
> 17a20
buildstream/_fuse/fuse.py
> 58a62
buildstream/_version.py
> 64a69
buildstream/plugins/elements/__init__.py
> 73a79
buildstream/plugins/elements/meson.py
> 78a85,86
buildstream/plugins/sources/__init__.py
buildstream/plugins/sources/_downloadablefilesource.py
> 95a104
buildstream/sourcetransform.py

Possible fixes

Removing them all.


To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information