Skip to content

Commit

Permalink
fix bandit and flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Santobert committed Apr 4, 2024
1 parent 9260b5e commit d6e8365
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pybotvac/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ def _message(self, json: dict, schema: Schema):
"""

try:
# pylint: disable=missing-timeout
response = requests.post(
self._url,
json=json,
verify=self._vendor.cert_path,
auth=Auth(self.serial, self.secret),
headers=self._headers,
timeout=10,
)
response.raise_for_status()
schema(response.json())
Expand Down
12 changes: 5 additions & 7 deletions pybotvac/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def _login(self, email: str, password: str):
"""

try:
# pylint: disable=missing-timeout
response = requests.post(
urljoin(self.endpoint, "sessions"),
json={
Expand All @@ -69,6 +68,7 @@ def _login(self, email: str, password: str):
"token": binascii.hexlify(os.urandom(64)).decode("utf8"),
},
headers=self.headers,
timeout=10,
)

response.raise_for_status()
Expand All @@ -94,8 +94,7 @@ def get(self, path, **kwargs):
url = self.urljoin(path)
headers = self.generate_headers(kwargs.pop("headers", None))
try:
# pylint: disable=missing-timeout
response = requests.get(url, headers=headers, **kwargs)
response = requests.get(url, headers=headers, timeout=10, **kwargs)
response.raise_for_status()
except (
requests.exceptions.ConnectionError,
Expand Down Expand Up @@ -208,7 +207,6 @@ def __init__(

def send_email_otp(self, email: str):
"""Request an authorization code via email."""
# pylint: disable=missing-timeout
response = requests.post(
self.vendor.passwordless_endpoint,
data=json.dumps(
Expand All @@ -220,12 +218,12 @@ def send_email_otp(self, email: str):
}
),
headers={"Content-Type": "application/json"},
timeout=10,
)
response.raise_for_status()

def fetch_token_passwordless(self, email: str, code: str):
"""Fetch an access token using the emailed code."""
# pylint: disable=missing-timeout
response = requests.post(
self.vendor.token_endpoint,
data=json.dumps(
Expand All @@ -245,6 +243,7 @@ def fetch_token_passwordless(self, email: str, code: str):
}
),
headers={"Content-Type": "application/json"},
timeout=10,
)
response.raise_for_status()
self._token = response.json()
Expand All @@ -257,8 +256,7 @@ def get(self, path: str, **kwargs) -> requests.Response:
headers["Authorization"] = "Auth0Bearer {}".format(self._token.get("id_token"))

try:
# pylint: disable=missing-timeout
response = requests.get(url, headers=headers)
response = requests.get(url, headers=headers, timeout=10)
response.raise_for_status()
except (
requests.exceptions.ConnectionError,
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ skip = ./.git,./.mypy_cache,./.vscode,./venv
exclude = .vscode,venv
max-line-length = 88
ignore =
F401, # Import error, pylint covers this
# Import error, pylint covers this
F401,
# Formatting errors that are covered by black
D202,
E203,
Expand Down

0 comments on commit d6e8365

Please sign in to comment.