Probably we don't need to introduce this variable here (doesn't help with line length).  We can use:

`if not (response.is_ok or response.status_code in expected_response_codes):`

  But If you feel like it helps readability - I'm ok with that.