arrayfire / arrayfire-python

Python bindings for ArrayFire: A general purpose GPU library.
https://arrayfire.com
BSD 3-Clause "New" or "Revised" License
416 stars 65 forks source link

Flake8 code style fixes #241

Closed roaffix closed 3 years ago

roaffix commented 3 years ago
roaffix commented 3 years ago

Most of utility abstractions look good although it seems majority of if checks are now contradicting PEP8 style in the following two patterns:

  1. if <var> is None: or if <var> is not None should be preferred over if <var>: per PEP8 guidline - https://www.python.org/dev/peps/pep-0008/#programming-recommendations
  2. if <var> == 0 or <some number> - not sure what's PEP8 stance on this type of comparisons, but numerical comparisons are better written this way to ensure better code readability and understanding instead of if <var>: which seems like checking for None and may lead to confusion.

You are right. Some variables are considered to be None by default, so it should be checked. Nice catch! I'll fix that. In other cases, some of your checks, e.g., AF_PATH in library.py check if AF_PATH is None, but it should fail if AF_PATH == "". Simple conditions change to if AF_PATH can fix such problems when the default value or variable type is not known.

roaffix commented 3 years ago

I'm going to postpone this PR till #244 is merged. I will add the arg --flake8 to the pytest for automatic code style checks here right after.