You have to keep Paul's (as well as David's) statement in context as we know there were righteous people.
Job 1:1
There was a man in the land of Uz, whose name was Job; and that man was perfect and upright, and one that feared God, and eschewed evil.
Lk 1:5-6
There was in the days of Herod, the king of Judaea, a certain priest named Zacharias, of the course of Abia: and his wife was of the daughters of Aaron, and her name was Elisabeth.And they were both righteous before God, walking in all the commandments and ordinances of the Lord blameless.