There's a mentality I've adopted that I find helpful that I call "hopeful pessimism". It's the descriptive form of "Hope for the best; prepare for the worst". You expect the worst outcome, but hope you're wrong.
I think most of the devs I've enjoyed working with have similar perspectives, and often include a dark sense of humor with it. As when the hope runs out, all you're left with is something dark, and being able to laugh at the absurdity of it, to make light of it and minimize it that way, is a helpful coping mechanism, as well as one that can help bind a team together. And also helps avoid falling into despair along the way as the hits come; you can stay hopeful and focused on the desired outcome.
I think most of the devs I've enjoyed working with have similar perspectives, and often include a dark sense of humor with it. As when the hope runs out, all you're left with is something dark, and being able to laugh at the absurdity of it, to make light of it and minimize it that way, is a helpful coping mechanism, as well as one that can help bind a team together. And also helps avoid falling into despair along the way as the hits come; you can stay hopeful and focused on the desired outcome.