Move imports to the top of the file, make flake8 happy

11 jobs for generate-swagger in 19 minutes and 11 seconds (queued for 10 seconds)
Name Stage Failure
failed
test_api_3.10 Test
Uploading artifacts for failed job
Uploading artifacts...
WARNING: api/report.xml: no matching files
ERROR: No files to upload
Uploading artifacts...
WARNING: api/coverage.xml: no matching files
ERROR: No files to upload
Cleaning up file based variables
ERROR: Job failed: exit code 1