The quoted sentence:
This is a two-sided test for the null hypothesis that 2 independent samples have identical average (expected) values.
is a reference to the population means not the sample means; it is otherwise misleading and should certainly be clearer but they do t least say "(expected) values", which can only be a reference to population means from which the samples were drawn.
However, you were understandably misled by it and if a student wrote that I would certainly mark it wrong (since it does seem to suggest that it is the sample means being tested for equality, just as it did to you).
Therefore I'm thinking what they really mean is that the Null Hypothesis is that both samples come from the same distribution. Is that correct?
Usually the hypothesis that people wish to test with this hypothesis test is $H_0: \mu_X=\mu_Y$, but when accompanied by the assumptions of the usual equal variance two sample t-test, that's the same as saying they come from the same distribution. The assumption of equal variances is the default for the scipy implementation of this test, but set otherwise it doesn't assume equal variances and then the null doesn't imply that distributions are the same.
That's true of many of the commonly used hypothesis tests -- that the null (when combined with the assumptions) amounts to assuming equal distributions.