Black is a popular python formater and is very common across many projects.
When some section of code should not be formatted it can be annotated with a trailing # fmt: skip
comment, similar to the # type: ignore
annotation for typing and other common tools.
When adding such a notation Sonar flags this as a violation of python:S139. This should be ignored as moving the comment would break the intended behavior control for Black.
See The Black code style — Black 21.9b0 documentation
Possible annotations are # fmt: skip
, # fmt: on
and # fmt: off
.
Example:
my_dict = {
'a': 1, 'b': 2,
'c': 3, 'z': 0
} # fmt: skip