Coverage for /home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/compat.py: 71%

7 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 14:22 +0000

1# Licensed to the Apache Software Foundation (ASF) under one 

2# or more contributor license agreements. See the NOTICE file 

3# distributed with this work for additional information 

4# regarding copyright ownership. The ASF licenses this file 

5# to you under the Apache License, Version 2.0 (the 

6# "License"); you may not use this file except in compliance 

7# with the License. You may obtain a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, 

12# software distributed under the License is distributed on an 

13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 

14# KIND, either express or implied. See the License for the 

15# specific language governing permissions and limitations 

16# under the License. 

17from __future__ import annotations 

18 

19from fastapi import status 

20 

21# HTTP_422_UNPROCESSABLE_CONTENT was added in Starlette 0.48.0, replacing HTTP_422_UNPROCESSABLE_ENTITY 

22# to align with RFC 9110 (HTTP Semantics). 

23# 

24# FastAPI 0.128.0 (our minimum version) requires starlette>=0.40.0. With "Low dep tests" 

25# (uv sync --resolution lowest-direct), starlette 0.40.0 is installed, which only has 

26# HTTP_422_UNPROCESSABLE_ENTITY. So we need this fallback for backward compatibility. 

27# 

28# Refs: 

29# - https://www.starlette.io/release-notes/ 

30# - https://www.rfc-editor.org/rfc/rfc9110#status.422 

31try: 

32 HTTP_422_UNPROCESSABLE_CONTENT = status.HTTP_422_UNPROCESSABLE_CONTENT 

33except AttributeError: 

34 HTTP_422_UNPROCESSABLE_CONTENT = status.HTTP_422_UNPROCESSABLE_ENTITY # type: ignore[attr-defined] 

35 

36__all__ = ["HTTP_422_UNPROCESSABLE_CONTENT"]