Use HTTP_OK constant (#33798)

* Use http ok constant

* Remove incorrect use

* Run isort

* Fix pylint by adding missing imports

* Fix pylint by fixing one import
This commit is contained in:
springstan 2020-04-08 18:47:38 +02:00 committed by GitHub
parent 7383e81609
commit 8d61893c39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 214 additions and 154 deletions

View file

@ -6,6 +6,7 @@ import requests
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import HTTP_OK
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
@ -83,7 +84,7 @@ class APIData:
def update(self):
"""Get the latest data from TFL."""
response = requests.get(URL, timeout=10)
if response.status_code != 200:
if response.status_code != HTTP_OK:
_LOGGER.warning("Invalid response from API")
else:
self.data = parse_api_response(response.json())