How do I set window length and shift length for computing STFT on Scipy?
for this function:

nperseg will set the number of samples to output from your STFT.
noverlap will specify how many old samples you want to take to calculate your future STFT.

Let's say you want a stft of size 256 with an overlap of 50% you will set noverlap = 128.
128 samples will then be taken from the old segment that was used to calculate the previous STFT...
For more information about STFT and the interest of overlap I invite you to watch this discussion.
STFT: why overlapping the window?