Petrov type $D$ gravitational fields, generated by a perfect fluid with spatially homogeneous energy density and with flow lines which form a nonshearing and nonrotating timelike congruence, are reexamined. It turns out that the anisotropic such spacetimes, which comprise the vacuum $C$ metric as a limit case, can have nonzero expansion, contrary to the conclusion in the original investigation by Barnes [A. Barnes, Gen. Relativ. Gravit. 4, 105 (1973).]. Apart from the static members, this class consists of cosmological models with precisely one symmetry. The general line element is constructed and some important properties are discussed. It is also shown that purely electric Petrov type $D$ vacuum spacetimes admit shear-free normal timelike congruences everywhere, even in the nonstatic regions. This result incited to deduce intrinsic, easily testable criteria regarding shear-free normality and staticity of Petrov type $D$ spacetimes in general, which are added in an appendix.