Is the residential rental property located outside the US? If so, then 40 years would be correct for property place in service prior to 2018.
US nonresidential real property is depreciated over 39 years. US residential rental property is depreciated over 27.5 years.