|
16 | 16 |
|
17 | 17 |
|
18 | 18 | class _CodesMeta(EnumMeta): |
19 | | - def __getattr__(cls, name: str) -> codes: |
| 19 | + def __getattribute__(cls, name: str) -> object: |
20 | 20 | if name in _DEPRECATED_CODES: |
21 | 21 | new_name = _DEPRECATED_CODES[name] |
22 | 22 | warnings.warn( |
23 | 23 | f"'{name}' is deprecated. Use '{new_name}' instead.", |
24 | 24 | category=DeprecationWarning, |
25 | 25 | stacklevel=2, |
26 | 26 | ) |
27 | | - return cls[new_name] |
28 | | - raise AttributeError(name) |
| 27 | + return super().__getattribute__(name) |
29 | 28 |
|
30 | 29 |
|
31 | 30 | class codes(IntEnum, metaclass=_CodesMeta): |
@@ -178,7 +177,13 @@ def is_error(cls, value: int) -> bool: |
178 | 177 | NOT_EXTENDED = 510, "Not Extended" |
179 | 178 | NETWORK_AUTHENTICATION_REQUIRED = 511, "Network Authentication Required" |
180 | 179 |
|
| 180 | + # Deprecated aliases for names replaced by RFC 9110. |
| 181 | + REQUEST_ENTITY_TOO_LARGE = CONTENT_TOO_LARGE |
| 182 | + REQUEST_URI_TOO_LONG = URI_TOO_LONG |
| 183 | + REQUESTED_RANGE_NOT_SATISFIABLE = RANGE_NOT_SATISFIABLE |
| 184 | + UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT |
| 185 | + |
181 | 186 |
|
182 | 187 | # Include lower-case styles for `requests` compatibility. |
183 | | -for code in codes: |
184 | | - setattr(codes, code._name_.lower(), int(code)) |
| 188 | +for name, code in codes.__members__.items(): |
| 189 | + setattr(codes, name.lower(), int(code)) |
0 commit comments