Cook's Partisan Voting Index (PVI) uses the presidential vote to determine the partisan lean of the district, not the congressional vote.
There's never been an uncontested presidential race, so that's never been a problem.
From Wikipedia:
PVIs are calculated by comparing the district's average Democratic or Republican Party's share of the two-party presidential vote in the past two presidential elections to the nation's average share of the same.
Or read the Cook Political Report explanation:
The Cook Political Report is pleased to introduce the 20th anniversary edition of the Partisan Voter Index (PVI) for all 50 states and 435 Congressional districts in the country, compiled especially for the Report by POLIDATA®. First introduced in 1997, the Cook PVI measures how each district performs at the presidential level compared to the nation as a whole. We have released new PVI scores following every election since 1996 and every round of redistricting since 2001, each time taking into account the prior two presidential elections.