All my lock cylinders have cover plates (built-in the key hole, not those hinged wing plates like GM/etc used to have on trunks), and all my keys are relatively clean, so I've never had an issue with a wet lube attracting dust, but I don't drive off-road in the desert.
However, WD40 is not a lubricant. It is fine to soften up a mechanism with many years old hardened grease, or flush out wear particles to get it moving better, but then it benefits from a light oil lube. This protects better against corrosion and wear than a dry lube, but once you have it flushed out, you could use a dry lube instead.