I think the best thing that you can do to ensure you still get security updates is either make sure you get a device with an unlocked bootloader or hope there's a root exploit available so you can put something like LinageOS[1] on it.
I picked up an Essential Phone (on the cheap) for the former even though they appear to be getting timely updates so far (one day behind pixel) if you're willing to sideload with adb (and promises of support for 3 years). Also managed to grab it for I don't think I'll ever buy an android phone that's not a pixel (formerly nexus) that's not unlocked again.
Edit: On second thought some of what I wrote is probably not correct[2].
[2] https://twitter.com/CopperheadOS/status/852833915073056769