I want to calculate
$$\int_{\gamma} \frac{\sin z}{z^2 + 1}dz$$ where $\gamma$ is the upper-half circle of radius 2 centered at the origin starting at 2. I know that since $\gamma$ is not a closed curve, Cauchy's theorem will be of no use, but I believe that the integrand has a singularity at i, which is between the curve and the real axis. Can I use the residue theorem here?
Residue theorem is the right way to go. Note that since the integrand is odd on $\mathbb R$,
$$ \int_{\gamma} \frac{\sin z}{z^2 + 1}dz = \int_{\gamma} \frac{\sin z}{z^2 + 1}dz + \int_{-2}^2 \frac{\sin z}{z^2 + 1}dz = 2\pi i \operatorname{Res}_{z=i}\left( \frac{\sin z}{z^2 + 1}\right)$$