1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-17 17:31:31 +00:00

[PR #11561/7436c0c9 backport][stable-12] replace literal HTTP codes with http.HTTPStatus (#11568)

replace literal HTTP codes with `http.HTTPStatus` (#11561)

* replace literal HTTP codes with http.HTTPStatus

* add changelog frag

(cherry picked from commit 7436c0c9ba)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2026-03-10 22:14:27 +01:00 committed by GitHub
parent b3782a76e0
commit 25c475a7ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 135 additions and 78 deletions

View file

@ -17,6 +17,7 @@ import re
import socket
import typing as t
import uuid
from http import HTTPStatus
from urllib.parse import quote
from ansible.module_utils.basic import AnsibleFallbackNotFound, env_fallback
@ -90,7 +91,7 @@ class IPAClient:
module=self.module, url=url, data=to_bytes(data), headers=headers, timeout=self.timeout
)
status_code = info["status"]
if status_code not in [200, 201, 204]:
if status_code not in (HTTPStatus.OK, HTTPStatus.CREATED, HTTPStatus.NO_CONTENT):
self._fail("login", info["msg"])
self.headers = {"Cookie": info.get("set-cookie")}
@ -145,7 +146,7 @@ class IPAClient:
use_gssapi=self.use_gssapi,
)
status_code = info["status"]
if status_code not in [200, 201, 204]:
if status_code not in (HTTPStatus.OK, HTTPStatus.CREATED, HTTPStatus.NO_CONTENT):
self._fail(method, info["msg"])
except Exception as e:
self._fail(f"post {method}", f"{e}")