22
33 - on aiohttp services
44 from servicelib.aiohttp import status
5- from servicelib.status_utils import is_success
5+ from servicelib.status_codes_utils import is_success
66
77 assert is_success(status.HTTP_200_OK)
88
99
1010 - on fastapi services
1111
1212 from fastapi import status
13- from servicelib.status_utils import is_success
13+ from servicelib.status_codes_utils import is_success
1414
1515 assert is_success(status.HTTP_200_OK)
1616
@@ -37,6 +37,7 @@ def get_code_display_name(status_code: int) -> str:
3737 return f"HTTP_{ status_code } _{ code .name } "
3838 except ValueError :
3939 if status_code == 306 : # noqa: PLR2004
40+ # NOTE: HttpStatus does not include 306
4041 return "HTTP_306_RESERVED"
4142 return _INVALID_STATUS_CODE_MSG
4243
@@ -65,35 +66,35 @@ def get_code_description(status_code: int) -> str:
6566 )
6667
6768
68- def is_informational (status_code : int ) -> bool :
69+ def is_1xx_informational (status_code : int ) -> bool :
6970 """
7071 Returns `True` for 1xx status codes, `False` otherwise.
7172 """
7273 return 100 <= status_code <= 199 # noqa: PLR2004
7374
7475
75- def is_success (status_code : int ) -> bool :
76+ def is_2xx_success (status_code : int ) -> bool :
7677 """
7778 Returns `True` for 2xx status codes, `False` otherwise.
7879 """
7980 return 200 <= status_code <= 299 # noqa: PLR2004
8081
8182
82- def is_redirect (status_code : int ) -> bool :
83+ def is_3xx_redirect (status_code : int ) -> bool :
8384 """
8485 Returns `True` for 3xx status codes, `False` otherwise.
8586 """
8687 return 300 <= status_code <= 399 # noqa: PLR2004
8788
8889
89- def is_client_error (status_code : int ) -> bool :
90+ def is_4xx_client_error (status_code : int ) -> bool :
9091 """
9192 Returns `True` for 4xx status codes, `False` otherwise.
9293 """
9394 return 400 <= status_code <= 499 # noqa: PLR2004
9495
9596
96- def is_server_error (status_code : int ) -> bool :
97+ def is_5xx_server_error (status_code : int ) -> bool :
9798 """
9899 Returns `True` for 5xx status codes, `False` otherwise.
99100 """
0 commit comments