This don't do what you want. I think you want:

os.path.splitext(filepath)[1] == ".pkl"

the dot stay, the extension is in the second field and you don't use the good path.