using os.scandir() results in 'unresolved attribute reference' warnings in pycharm

Viewed 546

I have the following python code in pycharm:

# search for files or folders with two or more adjacent spaces
def twoplusspaces(path):

    srchr = os.scandir(path) # get our iterator

    # iterate through folders and files looking for adjacent blank spaces
    for entry in srchr:
        if "  " in entry.name:
            print(entry.name) # print name of file/folder with 2+ spaces
        if entry.is_dir():
            twoplusspaces(path + "\\" + entry.name) # recursive call when folder encountered

    srchr.close() # done using iterator

This works fine as intended but pycharm is warning me 'unresolved attribute reference' for entry.name and entry.is_dir(). I find this odd because Python documentation says these attributes exist for the DirEntry object that is returned by scandir(): https://docs.python.org/3/library/os.html#os.DirEntry

Looks like there might be an issue with my pycharm but not sure... Any help or elaboration on this matter is appreciated, thanks!

1 Answers

Looks like this is a bug with pycharm. Will ignore for now then. Thanks Steve!

Related