Skip to content

Commit

Permalink
chore: fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Oct 13, 2023
1 parent 67902c0 commit b231ab6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/schemathesis/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,10 @@ def shutdown() -> None:


def handle_service_error(exc: requests.HTTPError, api_name: str) -> NoReturn:
if exc.response.status_code == 403:
error_message(exc.response.json()["detail"])
elif exc.response.status_code == 404:
response = cast(requests.Response, exc.response)
if response.status_code == 403:
error_message(response.json()["detail"])
elif response.status_code == 404:
error_message(f"API with name `{api_name}` not found!")
else:
output.default.display_service_error(service.Error(exc))
Expand Down Expand Up @@ -1354,7 +1355,8 @@ def login(token: str, hostname: str, hosts_file: str, protocol: str, request_tls
service.hosts.store(token, hostname, hosts_file)
success_message(f"Logged in into {hostname} as " + bold(username))
except requests.HTTPError as exc:
detail = exc.response.json()["detail"]
response = cast(requests.Response, exc.response)
detail = response.json()["detail"]
error_message(f"Failed to login into {hostname}: " + bold(detail))
sys.exit(1)

Expand Down
3 changes: 2 additions & 1 deletion src/schemathesis/cli/output/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ def display_report_metadata(meta: service.Metadata) -> None:
def display_service_error(event: service.Error) -> None:
"""Show information about an error during communication with Schemathesis.io."""
if isinstance(event.exception, requests.HTTPError):
status_code = event.exception.response.status_code
response = cast(requests.Response, event.exception.response)
status_code = response.status_code
click.secho(f"Schemathesis.io responded with HTTP {status_code}", fg="red")
if 500 <= status_code <= 599:
# Server error, should be resolved soon
Expand Down

0 comments on commit b231ab6

Please sign in to comment.