-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Black breaks comment formatting for slurm/pbs cluster directives. #1024
Comments
#960 attempted to address this issue with a special-case for these directives, but it seems clear in #1014 that a purely special-case solution isn't practical in the long term. @JelleZijlstra @edreamleo would an escape hatch option |
I think that's the best solution I've seen so far, even though it would make Black produce code that's technically not PEP-8 compliant. But maybe it's the pragmatic choice. |
Yes, for clarity for incoming readers, the explicit ask in the referenced PRs is for a form on non-pep8 compliant output for semantically overloaded comments. |
I came across the very same problem and would very much appreciate a pragmatic solution. |
Similarly, Leo's sentinel comments are not pep-8. Leo now does allow whitespace between the '#" and '@', but that creates other problems, including massive diffs after blackening files. In short, a pragmatic solution would be very much appreciated. It would be good if black could be told not to munge some (or all) comments. Thanks. |
I think the pragmatic solution would be to make |
I do agree that However, according to the OP that's not an option for these |
I've just tried running a job with |
Emphasis added |
I can confirm this is the behavior I observe as well. #!/usr/bin/env python3
# fmt: off
#SBATCH --time=2-00:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=40
#SBATCH --mail-type=all
#SBATCH -J test
#SBATCH --qos=long
#SBATCH -o test.log
# test
from time import sleep
sleep(10)
print(123)
# fmt: on It's ugly, but at least works. |
Let's make a decision in #3668. |
Slurm and PBS use block comments of the form
#SBATCH
or#PBS
immediately following the#!
header to provide default configuration parameters for a batch scheduler. Unfortunately, these tools don't support a pep8 compatible# SBATCH
or# PBS
syntax.Applying black to a script with
#SBATCH
and#PBS
directives silently breaks these tools, in that:is reformatted as:
causing the
--exclusive
directive to be ignored by SLURM.As the directive must follow the shebang and must not have a space between
#
andSBATCH
. As such a# fmt: off
escape hatche isn't a viable solution and (interestingly) don't prevent block comment reformatting in black's current implementation.The text was updated successfully, but these errors were encountered: