move function specific imports to function
move function specific imports to function

re: 1a11a1a1eb48c316820004b802f5151ff9db3f86@asottile that this should only get imported in the function
modify the else/if logic since inside the function we already know the python version is >= 3.10, and just have to know if it is 3.11 or greater
markshao/pytest,Akasurde/pytest,RonnyPfannschmidt/pytest,pytest-dev/pytest