Pylint failed for my code, and research led me to this post:
../filename.py:49:11: C1801: Do not use 'len(SEQUENCE)' to determine if a sequence is empty (len-as-condition) ../filename.py:49:34: C1801: Do not use 'len(SEQUENCE)' to determine if a sequence is empty (len-as-condition)
This has been my code before:
def list_empty_folders(directory): """The Module Has Been Build to list empty Mac Folders.""" for (fullpath, dirnames, filenames) in os.walk(directory): if len(dirnames) == 0 and len(filenames) == 0: print("Exists: {} : Absolute Path: {}".format( os.path.exists(fullpath), os.path.abspath(fullpath)))
This was after fixing my code. Using attribute int() , I seem to satisfy Pep8 / Pylint and does not seem to have a negative effect on my code:
def list_empty_folders(directory): """The Module Has Been Build to list empty Mac Folders.""" for (fullpath, dirnames, filenames) in os.walk(directory): if len(dirnames).__trunc__() == 0 and len(filenames).__trunc__() == 0: print("Exists: {} : Absolute Path: {}".format( os.path.exists(fullpath), os.path.abspath(fullpath)))
My fix
By adding .__trunc__() to the sequence, it seems to have exhausted the need.
I do not see differences in behavior, but if someone knows the features that I am missing, please let me know.
JayRizzo Apr 3 '19 at 19:31 2019-04-03 19:31
source share