As general managers across MLB hang on to hope that they may not have to sell before the July 31 trade deadline, at least one is facing reality.

That may be good news for the Yankees, who could be interested in Diamondbacks starter Robbie Ray, the lefty whose general manager sounds like he’s leaning towards selling.

“The belief that a .500 team is going to win the World Series, get through the wild-card format that we have and win the World Series is, I don’t think objectively that’s a position we should be staking ourselves to,” Diamondbacks GM Mike Hazen told reporters Monday.

The Diamondbacks entered Tuesday at 51-50, tied for second place in the NL West but two games back of the final wild-card spot in a crowded field.

Ray put them above .500 Monday night, tossing six innings and allowing three runs while striking out 10 in a 6-3 win. The 27-year-old, under team control and arbitration-eligible through 2020, now has a 3.95 ERA across 22 starts.

The number of high-end pitchers once thought to be available leading up to the trade deadline seems to be shrinking. Madison Bumgarner’s Giants have won 16 of 19 to surge into the playoff race — now with the same 51-50 record as Arizona — while Trevor Bauer’s Indians are now just three games back of the Twins in the AL Central.

The Diamondbacks, meanwhile, have had Tim Wilken, a special assistant to Hazen, in Tampa scouting the Yankees’ Single-A team, The Post reported July 12.

While Ray has been solid, the Diamondbacks have hovered around .500 over the last month, often playing against other teams in the race.

“It’s not a great recipe to — it’s a recipe that is forcing us to at least consider all options, put it that way,” Hazen said.