I'm trying to work out $$I=\mathcal{P} \int_{-\infty}^{\infty} \frac{dz}{z-i}$$
where $\mathcal{P}$ denotes the fact we are taking the Cauchy principal value.
Let $\gamma$ be the contour such that $\gamma = \gamma_1 + \gamma_R$, where $\gamma_1 = [-R, R]$ from left to right, $\gamma_R$ is the top half of the circle centered at $0$ of radius $R$, traversed anti-clockwise.
Then for $R>1$, $\oint_{\gamma} \frac{dz}{z-i}$ is equal to $2 \pi i$ by Cauchy's integral formula. $\int_{\gamma_R} \frac{dz}{z-i} \to 0$ as $R \to \infty$ by Jordan's lemma, and $\int_{\gamma_1} \frac{dz}{z-i} \to I$ as $R \to \infty$. So I get $I = 2 \pi i$.
But it seems to me that the actual answer should be $I = \pi i$, at least according to Wolfram Alpha and this integral calculator. I highly doubt both of these are wrong, but I'm struggling to see what I've done wrong here; I don't spot which theorem or formula was applied incorrectly to me in my working. Can someone point out where I've picked up the extra factor of $2$?
You are mistaken about the use of the Jordan's lemma. The Jordan's lemma states that the integral of $e^{i\alpha z}f(z)$ over the top half-circle of radius $R$ passed counter-clockwise tends to zero, if $f(z)=o(1)$ and $\alpha \in \mathbb{R}_{+}$. But here you do not have the exponent. You may also mix the Jordan's lemma with the stiuation when $f(x)$ is $o(\frac{1}{x})$ and thus the integral tends to zero at infinity due to simple upper bound on its absolute value: $$\left|\int_{\gamma} f(z)dz\right|\le \int_{\gamma}|f(z)|dz \le \max_{\gamma}|f(z)|\cdot \text{ length of }\gamma = \max_{\gamma}|f(z)|\cdot \pi R$$
but here again you do not have the $o\left(\frac{1}{x}\right)$ decay, only $\Theta\left(\frac{1}{x}\right)$
To calculate the principal value of this integral, you can use the semi-residue lemma, or just do it by definition.
$\newcommand{\eps}{\epsilon}$
Proof of the lemma:
$$I_{\eps}=\int_{\frac{1}{2}U_{\eps}(z_{0})}\frac{\varphi(z)-\varphi(z_{0})}{z-z_{0}}dz+\varphi(z_{0})\int_{\frac{1}{2}U_{\eps}(z_{0})} \frac{1}{z-z_{0}}dz$$ The second integral can be calculated explicitly unsing parametrization: $z=z_{0}+\eps e^{ i \varphi }$. $$\varphi(z_{0})\int_{0}^{\pi} \frac{i \eps e^{ i\varphi }}{\eps e^{ i\varphi }} d\varphi=i\pi\varphi(z_{0})$$ The first integral is $o(1)$, since it is $\frac{o(1)}{\eps}\pi \eps$, because $\varphi(z)$ is continuous.
Note that "semi-residue" is just a mnemonic: $f(z)$ does not have to be analytic in the neighborhood of $z_0$, and the proof does not depend on the Cauchy formula and the lemma on residues.