This is exactly the same attitude toward office politics I held, back before my naïveté on the subject cost me a job I'd have liked to keep.

The short version: You will almost certainly find yourself confronted with the need to participate in office politics sooner or later. Best you accept this fact now and learn at least the modicum necessary to defend yourself, because taking the stance that your principles place you above it all will only make you a target. Moreover, equating participation in office politics with Machiavellian bastardry is at best enormously naïve; sufficient acumen, which is well within the capabilities of almost any skillful programmer, will enable you to play a positive-sum game.

The long version:

In some organizations, it's unnecessary to know anything about office politics, because they don't exist -- a rare and happy state which obtained for the first decade of my career, and was fine as far as it went, but which left me utterly unprepared to deal competently with them once my desire to advance my career and my craft made it necessary for me to do so.

In some other organizations, or so I assume, it's unnecessary to know much about office politics because, while they exist, it's possible to avoid participation. I can't speak to such situations from personal experience, but presumably they call for at least some modicum of knowledge on the subject, in order adroitly to avoid having any stance on a political matter -- at the very least, you'd need to be able to identify such matters, in order to avoid letting sheer ignorance betray you into taking a stance.

In most organizations, as far as I can tell, it is absolutely necessary to know something about how to play the game, because you're required to sit down at the table simply by virtue of being part of the organization at all. In such a situation, there are absolutely no advantages to the belief that your principles require you to remain above it all.

On the one hand, the attitude that political acumen is unworthy of you will lead you into ignorance which will eventually betray you in the fashion I describe above. On the other, it'll be more or less impossible to preserve indefinitely the belief among your fellows that you're simply innocent of it all, which is the best you can hope for; eventually, people will realize that you regard the whole matter with contempt, which they will take personally, whether you so intend it or otherwise.

This being the case, once your true opinion of the matter becomes apparent to your fellows, your days in the organization are numbered, because however they'd otherwise be inclined to regard you, you have just given everyone a reason to regard you as a political enemy, and rightly so -- after all, no one loves being held in contempt, nor should he.

Having thus disposed of the question of the value, or lack thereof, inhering in the principled stance above politics, all that remains to consider is one's degree of competence in that realm, and the only sensible opinion here is that one should develop as much competence as her natural talent makes possible. Just as with any other skill critical to one's successful pursuit of her career goals, it makes no sense to aim for any lesser degree of attainment.

Given my own experiences at the hands of office politicians, I can certainly empathize with your apparent distaste for that entire realm of human endeavor. On the other hand, those same experiences lead me to regard the principled stance above politics as arrant foolishness, because if you're in an environment where such politics exist at all, your alternatives are but two: you may retain your principled stance and rely upon good fortune, which will eventually exhaust itself and more probably sooner than later, to save you harming yourself through careless ignorance; or you may study the subject, at least to the extent necessary to arm you in self-defense, and ideally to the rather greater extent which will allow you to play the game as necessary, to the benefit of both the organization and yourself.

After all, just because the game of office politics is so often played in unprincipled fashion, you need not also behave in a manner unequal with your own principles. You just need to be good enough at the game to get away with it, and that's another matter entirely. Whether Machiavelli's opus is of value in such a pursuit, I cannot say, because it's been many years since I read it, and I've never done so with an eye toward the direct personal utility of such advice. But if you're going to be stuck playing the game, wouldn't you agree that it's better to do so well than poorly?

(Update: For an example of what I mean by "playing the game well", see [1], where I describe how to avoid both the risk of coming off as an unmotivated time-server, and the risk that your colleagues will feel like you're outdoing them and making them look bad.)

[1] https://news.ycombinator.com/item?id=7767987