How to ignore single-line if-else statement validation in flake8?

Viewed 248

I have lots of single-line if-else statement in source code as below.

if i == 4: break

When I compile the source code using flake8, it transforms them into double-line codes as below.

if i == 4:
   break

Is there a way to ignore this special case in flake8?

1 Answers

If you want to ignore this error throughout your project, you could add the relevant error code (E701) to the ignore list in your configuration file:

[flake8]
ignore = E701

You could also control this in a more fine-grained manner and ignore specific occurrences of the error by adding a # noqa: E701 comment to the relevant statements.

Related