UNTIL recently, the SNP had reason to be grateful that Glenrothes was a former traditional Labour heartland where the Tories are still regarded with customary hostility, because otherwise the surprisingly high amount of local anti-European Union sentiment might have proved to be a difficulty in 2017 and 2019.

Under the former boundaries, the constituency recorded a 48% Leave vote at the 2016 EU referendum, higher than in all but four other Scottish constituencies.

Although few voters in Glenrothes are likely to consciously switch from the SNP back to Labour specifically because of Keir Starmer’s new status as a born-again Brexiteer, the hefty Leave vote may be reflective of a somewhat less liberal and more socially conservative electorate than exists in most other former Labour strongholds in Scotland. That could potentially smooth the path to a Labour comeback – if local voters are less hostile to Starmer’s positioning on immigration and social issues.

That said, there are plenty of other indicators that the SNP may actually be better placed to hold Labour off than in many other seats.

Tricia Marwick first gained the overlapping Holyrood constituency of Central Fife for the SNP in 2007, even though it had been the seemingly safe seat of former Labour first minister Henry McLeish just four years earlier. And 2007 was an election in which the SNP only won just over a quarter of constituencies in Scotland and were less than one point ahead of Labour in the national popular vote.

That suggests Glenrothes is the type of place where the SNP can prosper even when they’re not dominant nationally, as they certainly don’t appear to be this year.

Recent results for the UK Parliament constituency show a similar pattern. In 2017, the year of the Corbyn surge, Glenrothes was not one of the handful of seats that Labour took back, and nor was it one of the much larger number of seats in which they ran the SNP very close.

READ MORE: John Swinney: Scotland's voice 'simply doesn't matter to Westminster'

The SNP’s Peter Grant held on by a fairly comfortable eight-point margin – and increased that to 28 points in 2019. If the boundaries had remained unchanged, that would have meant that Labour wouldn’t have been able to gain the seat this year on a uniform swing if they were behind the SNP nationally.

Unfortunately the boundary revision has muddied the waters slightly. On the notional results from 2019, the SNP majority in the new Glenrothes and Mid Fife seat is only 22 points, which on paper means Labour could make the gain even if they are as much as four points behind across Scotland.

However, that might be slightly misleading, because the constituency’s new territory is being transferred from Kirkcaldy and Cowdenbeath, where the SNP’s vote was significantly lower in 2019 than it otherwise would have been due to the suspension of the ultimately successful SNP candidate Neale Hanvey (now with Alba) and the withdrawal of party support from his campaign.

One slight oddity is that although the SNP are the defending party in Glenrothes and Mid Fife, Labour are probably the party with the best-known candidate. Richard Baker was previously a Labour list MSP, albeit in the north-east rather than Fife, whereas the SNP are fielding local councillor John Beare as Grant is stepping down.

Grant will take with him bittersweet memories of his electoral battles in Glenrothes, because although he eventually won there on three occasions, he was also famously the losing SNP candidate in the constituency’s 2008 by-election, a slugfest that one or two over-excitable observers at the time considered to have historical significance on a par with the Battle of Stalingrad.

In retrospect the outcome seems much more like a hiccup, and at worst may have delayed the SNP’s progress towards a Westminster breakthrough by a handful of years.

At the time of that setback, the SNP held only seven seats in the House of Commons. If John Beare can take Glenrothes and Mid Fife for the party on July 4, even by the narrowest of margins, it will be a strong indication that they are likely to continue to have much more substantial representation than that in the next parliament.