In Qt Designer 5.9 the verticalLayout in test.ui had a certain distance to the edge of the window, but after loading test.ui with PyQt
Based off @eyllanesc's answer, here's a monkey patch that fixed the issue for me.
This solution works because the only code inside PyQt5 that cares about the WidgetStack.topIsLayoutWidget attribute is the UIParser.createLayout() method, and it only uses that attribute to decide whether to set the default margins to zero.
from PyQt5.uic import uiparser
uiparser.WidgetStack.topIsLayoutWidget = lambda self: False