def strip(self) -> Source:
        """Return new Source object with trailing and leading blank lines removed."""
        start, end = 0, len(self)
        while start < end and not self.lines[start].strip():
            start += 1
        while end > start and not self.lines[end - 1].strip():
            end -= 1
        source = Source()
        source.raw_lines = self.raw_lines
        source.lines[:] = self.lines[start:end]
        return source
Return new Source object with trailing and leading blank lines removed.
src/_pytest/_code/source.py