Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flake8: E743 ambiguous function definition 'O'

When I run flake8 on a file that only has one line: def O(): pass I got the following error, despite the function runs just fine:

/tmp/a.py:1:5: E743 ambiguous function definition 'O'

Why flake8 is failing? And why I don't just get warnings?

like image 771
d33tah Avatar asked Dec 06 '22 12:12

d33tah


2 Answers

From the documentation:

Do not define functions named 'l', 'o', or 'i' (E743)
Functions named I, O, and l can be very hard to read. This is because the letter I and the letter l are easily confused, and the letter O and the number 0 can be easily confused.

Change the names of these functions to something more descriptive.

Additional links
- https://www.python.org/dev/peps/pep-0008/#names-to-avoid

like image 186
Patrick Haugh Avatar answered Dec 08 '22 02:12

Patrick Haugh


flake8 is a utility for enforcing pep8 style consistency across Python projects, and according to pep8 function naming conventions: Function names should be lowercase, with words separated by underscores as necessary to improve readability.

If you want flake8 to ignore this specific error (which is against linting purpose) either add this to your setup.cfg file:

[flake8]
ignore = E743

or run it using the following option: flake8 --ignore=E743

But if you want just that flake8 does not fail and just show warning you have to run it with --exit-zero:

flake8 --exit-zero
like image 34
Dhia Avatar answered Dec 08 '22 02:12

Dhia