From d1eba24393819a6182f0ef2daada366f4f3e3d96 Mon Sep 17 00:00:00 2001
From: Jarek Potiuk <jarek@potiuk.com>
Date: Wed, 22 Dec 2021 18:34:18 +0100
Subject: [PATCH 1/2] Removes Python 3.6 support

Python 3.6 End of Life was on December 23, 2021

Airflow supports Python versions up to the moment they reach
end of life as documented in:

https://github.com/apache/airflow/blob/main/README.md#support-for-python-and-kubernetes-versions

RIP Python 3.6
---
 BREEZE.rst                                         | 14 +++++++-------
 CI.rst                                             |  2 +-
 IMAGES.rst                                         |  2 +-
 breeze-complete                                    |  2 +-
 dev/REFRESHING_CI_CACHE.md                         |  4 ++--
 dev/prepare_prod_docker_images.sh                  |  2 +-
 dev/provider_packages/prepare_provider_packages.py |  2 +-
 dev/retag_docker_images.py                         |  2 +-
 scripts/ci/libraries/_initialization.sh            |  4 ++--
 scripts/ci/selective_ci_checks.sh                  |  2 --
 setup.cfg                                          |  7 ++-----
 setup.py                                           |  3 +--
 tests/bats/breeze/test_breeze_complete.bats        |  8 ++++----
 13 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/BREEZE.rst b/BREEZE.rst
index 0cf6c12b00420..b809169eb96dd 100644
--- a/BREEZE.rst
+++ b/BREEZE.rst
@@ -1271,7 +1271,7 @@ This is the current syntax for  `./breeze <./breeze>`_:
 
           One of:
 
-                 3.7 3.8 3.9 3.6
+                 3.7 3.8 3.9
 
   -a, --install-airflow-version INSTALL_AIRFLOW_VERSION
           Uses different version of Airflow when building PROD image.
@@ -1474,7 +1474,7 @@ This is the current syntax for  `./breeze <./breeze>`_:
 
           One of:
 
-                 3.7 3.8 3.9 3.6
+                 3.7 3.8 3.9
 
   -I, --production-image
           Use production image for entering the environment and builds (not for tests).
@@ -1541,7 +1541,7 @@ This is the current syntax for  `./breeze <./breeze>`_:
 
           One of:
 
-                 3.7 3.8 3.9 3.6
+                 3.7 3.8 3.9
 
   -v, --verbose
           Show verbose information about executed docker, kind, kubectl, helm commands. Useful for
@@ -1632,7 +1632,7 @@ This is the current syntax for  `./breeze <./breeze>`_:
 
           One of:
 
-                 3.7 3.8 3.9 3.6
+                 3.7 3.8 3.9
 
 
   ####################################################################################################
@@ -1827,7 +1827,7 @@ This is the current syntax for  `./breeze <./breeze>`_:
 
           One of:
 
-                 3.7 3.8 3.9 3.6
+                 3.7 3.8 3.9
 
   -b, --backend BACKEND
           Backend to use for tests - it determines which database is used.
@@ -1896,7 +1896,7 @@ This is the current syntax for  `./breeze <./breeze>`_:
 
           One of:
 
-                 3.7 3.8 3.9 3.6
+                 3.7 3.8 3.9
 
   -F, --force-build-images
           Forces building of the local docker images. The images are rebuilt
@@ -2305,7 +2305,7 @@ This is the current syntax for  `./breeze <./breeze>`_:
 
           One of:
 
-                 3.7 3.8 3.9 3.6
+                 3.7 3.8 3.9
 
   ****************************************************************************************************
    Choose backend to run for Airflow
diff --git a/CI.rst b/CI.rst
index 9f289b608801b..d54d5a160a42c 100644
--- a/CI.rst
+++ b/CI.rst
@@ -662,7 +662,7 @@ have to be percent-encoded when you access them via UI (/ = %2F)
 +--------------+----------------------------------------------------------+----------------------------------------------------------+
 
 * <BRANCH> might be either "main" or "v2-*-test"
-* <X.Y> - Python version (Major + Minor).Should be one of ["3.6", "3.7", "3.8", "3.9"].
+* <X.Y> - Python version (Major + Minor).Should be one of ["3.7", "3.8", "3.9"].
 * <COMMIT_SHA> - full-length SHA of commit either from the tip of the branch (for pushes/schedule) or
   commit from the tip of the branch used for the PR.
 
diff --git a/IMAGES.rst b/IMAGES.rst
index 559ecdbd12545..913cd02a1339a 100644
--- a/IMAGES.rst
+++ b/IMAGES.rst
@@ -603,7 +603,7 @@ which checks if the image has been released and will pull it and rebuild it if n
     export FORCE_ANSWER_TO_QUESTIONS="true"
     export CI="true"
 
-    for python_version in "3.6" "3.7" "3.8"
+    for python_version in "3.7" "3.8" "3.9"
     do
             ./breeze build-image --python ${python_version} --build-cache-local \
                     --check-if-python-base-image-updated --verbose
diff --git a/breeze-complete b/breeze-complete
index ccc413c5fb4ae..dbf1388bcfaf3 100644
--- a/breeze-complete
+++ b/breeze-complete
@@ -23,7 +23,7 @@
 # by the BATS tests automatically during pre-commit and CI
 # Those cannot be made read-only as the breeze-complete must be re-sourceable
 
-_breeze_allowed_python_major_minor_versions="3.7 3.8 3.9 3.6"
+_breeze_allowed_python_major_minor_versions="3.7 3.8 3.9"
 _breeze_allowed_backends="sqlite mysql postgres mssql"
 _breeze_allowed_integrations="cassandra kerberos mongo openldap pinot rabbitmq redis statsd trino all"
 _breeze_allowed_generate_constraints_modes="source-providers pypi-providers no-providers"
diff --git a/dev/REFRESHING_CI_CACHE.md b/dev/REFRESHING_CI_CACHE.md
index b98d97c4807db..889efd716acaf 100644
--- a/dev/REFRESHING_CI_CACHE.md
+++ b/dev/REFRESHING_CI_CACHE.md
@@ -48,7 +48,7 @@ manual refresh might be needed.
 # Manually generating constraint files
 
 ```bash
-export CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING="3.7 3.8 3.9 3.6"
+export CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING="3.7 3.8 3.9"
 for python_version in $(echo "${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}")
 do
   ./breeze build-image --upgrade-to-newer-dependencies --python ${python_version} --build-cache-local
@@ -90,5 +90,5 @@ If you have fast network and powerful computer, you can refresh the images in pa
 or with gnu parallel:
 
 ```bash
-parallel -j 4 --linebuffer --tagstring '{}' ./dev/refresh_images.sh ::: 3.7 3.8 3.9 3.6
+parallel -j 4 --linebuffer --tagstring '{}' ./dev/refresh_images.sh ::: 3.7 3.8 3.9
 ```
diff --git a/dev/prepare_prod_docker_images.sh b/dev/prepare_prod_docker_images.sh
index dfccd9143f194..17dd1c7d98359 100755
--- a/dev/prepare_prod_docker_images.sh
+++ b/dev/prepare_prod_docker_images.sh
@@ -20,7 +20,7 @@ export AIRFLOW_SOURCES_DIR
 
 set -e
 
-CURRENT_PYTHON_MAJOR_MINOR_VERSIONS=("3.7" "3.8" "3.9" "3.6")
+CURRENT_PYTHON_MAJOR_MINOR_VERSIONS=("3.7" "3.8" "3.9")
 
 usage() {
     local cmdname
diff --git a/dev/provider_packages/prepare_provider_packages.py b/dev/provider_packages/prepare_provider_packages.py
index 7432bc0c5847d..c840348a5f496 100755
--- a/dev/provider_packages/prepare_provider_packages.py
+++ b/dev/provider_packages/prepare_provider_packages.py
@@ -52,7 +52,7 @@
 
 from airflow.utils.yaml import safe_load
 
-ALL_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
+ALL_PYTHON_VERSIONS = ["3.7", "3.8", "3.9"]
 
 INITIAL_CHANGELOG_CONTENT = """
 
diff --git a/dev/retag_docker_images.py b/dev/retag_docker_images.py
index 09faff025f82f..459f2c57c09e3 100755
--- a/dev/retag_docker_images.py
+++ b/dev/retag_docker_images.py
@@ -31,7 +31,7 @@
 
 import click
 
-PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
+PYTHON_VERSIONS = ["3.7", "3.8", "3.9"]
 
 GHCR_IO_PREFIX = "ghcr.io"
 
diff --git a/scripts/ci/libraries/_initialization.sh b/scripts/ci/libraries/_initialization.sh
index aa59270c6392f..533db37334347 100644
--- a/scripts/ci/libraries/_initialization.sh
+++ b/scripts/ci/libraries/_initialization.sh
@@ -107,11 +107,11 @@ function initialization::initialize_base_variables() {
     export PRODUCTION_IMAGE="false"
 
     # All supported major/minor versions of python in all versions of Airflow
-    ALL_PYTHON_MAJOR_MINOR_VERSIONS+=("3.6" "3.7" "3.8" "3.9")
+    ALL_PYTHON_MAJOR_MINOR_VERSIONS+=("3.7" "3.8" "3.9")
     export ALL_PYTHON_MAJOR_MINOR_VERSIONS
 
     # Currently supported major/minor versions of python
-    CURRENT_PYTHON_MAJOR_MINOR_VERSIONS+=("3.7" "3.8" "3.9" "3.6")
+    CURRENT_PYTHON_MAJOR_MINOR_VERSIONS+=("3.7" "3.8" "3.9")
     export CURRENT_PYTHON_MAJOR_MINOR_VERSIONS
 
     # Currently supported versions of Postgres
diff --git a/scripts/ci/selective_ci_checks.sh b/scripts/ci/selective_ci_checks.sh
index a8da6c1d8baeb..1f0fbd863437d 100755
--- a/scripts/ci/selective_ci_checks.sh
+++ b/scripts/ci/selective_ci_checks.sh
@@ -125,9 +125,7 @@ function output_all_basic_variables() {
     initialization::ga_output default-helm-version "${HELM_VERSION}"
 
     if [[ ${FULL_TESTS_NEEDED_LABEL} == "true" ]]; then
-        initialization::ga_output postgres-exclude '[{ "python-version": "3.6" }]'
         initialization::ga_output mysql-exclude '[{ "python-version": "3.7" }, { "python-version": "3.9" }]'
-        initialization::ga_output mssql-exclude '[{ "python-version": "3.6" }, { "python-version": "3.8" }]'
         initialization::ga_output sqlite-exclude '[{ "python-version": "3.7" }, { "python-version": "3.8" }]'
     else
         initialization::ga_output postgres-exclude '[]'
diff --git a/setup.cfg b/setup.cfg
index be2cc4d78aeae..f7432996948c4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -54,7 +54,6 @@ classifiers =
     Intended Audience :: Developers
     Intended Audience :: System Administrators
     License :: OSI Approved :: Apache Software License
-    Programming Language :: Python :: 3.6
     Programming Language :: Python :: 3.7
     Programming Language :: Python :: 3.8
     Programming Language :: Python :: 3.9
@@ -70,7 +69,7 @@ project_urls =
 [options]
 zip_safe = False
 include_package_data = True
-python_requires = ~=3.6
+python_requires = ~=3.7
 packages = find:
 setup_requires =
     gitpython
@@ -86,10 +85,8 @@ install_requires =
     attrs>=20.0, <21.0
     blinker
     cached_property~=1.5;python_version<="3.7"
-    # cattrs >= 1.1.0 dropped support for Python 3.6
-    cattrs>=1.0, <1.1.0;python_version<="3.6"
     # cattrs >= 1.7.0 break lineage - see https://github.com/apache/airflow/issues/16172
-    cattrs~=1.1, <1.7.0;python_version>"3.6"
+    cattrs~=1.1, <1.7.0
     # Required by vendored-in connexion
     clickclick>=1.2
     colorlog>=4.0.2, <6.0
diff --git a/setup.py b/setup.py
index cea42f5031a45..5ca559201c5e0 100644
--- a/setup.py
+++ b/setup.py
@@ -238,7 +238,6 @@ def write_version(filename: str = os.path.join(*[my_dir, "airflow", "git_version
 ]
 dask = [
     'cloudpickle>=1.4.1, <1.5.0',
-    'dask<2021.3.1;python_version<"3.7"',  # dask stopped supporting python 3.6 in 2021.3.1 version
     'dask>=2.9.0, <2021.6.1;python_version>="3.7"',  # dask 2021.6.1 does not work with `distributed`
     'distributed>=2.11.1, <2.20',
 ]
@@ -872,7 +871,7 @@ def is_package_excluded(package: str, exclusion_list: List[str]) -> bool:
 
 def sort_extras_requirements() -> Dict[str, List[str]]:
     """
-    For Python 3.6+ the dictionary order remains when keys() are retrieved.
+    The dictionary order remains when keys() are retrieved.
     Sort both: extras and list of dependencies to make it easier to analyse problems
     external packages will be first, then if providers are added they are added at the end of the lists.
     """
diff --git a/tests/bats/breeze/test_breeze_complete.bats b/tests/bats/breeze/test_breeze_complete.bats
index 69c725821b608..c7a5db981a310 100644
--- a/tests/bats/breeze/test_breeze_complete.bats
+++ b/tests/bats/breeze/test_breeze_complete.bats
@@ -25,7 +25,7 @@
   source "${AIRFLOW_SOURCES}/breeze-complete"
 
   breeze_complete::get_known_values_breeze "-p"
-  assert_equal "${_breeze_known_values}" "3.7 3.8 3.9 3.6"
+  assert_equal "${_breeze_known_values}" "3.7 3.8 3.9"
 }
 
 @test "Test get_known_values long" {
@@ -34,7 +34,7 @@
   source "${AIRFLOW_SOURCES}/breeze-complete"
 
   breeze_complete::get_known_values_breeze "--python"
-  assert_equal "${_breeze_known_values}" "3.7 3.8 3.9 3.6"
+  assert_equal "${_breeze_known_values}" "3.7 3.8 3.9"
 }
 
 @test "Test wrong get_known_values" {
@@ -125,7 +125,7 @@
   COMP_WORDS=("--python" "")
   breeze_complete::_comp_breeze
 
-  assert_equal "${COMPREPLY[*]}" "3.7 3.8 3.9 3.6"
+  assert_equal "${COMPREPLY[*]}" "3.7 3.8 3.9"
 }
 
 @test "Test autocomplete --python with prefix" {
@@ -136,7 +136,7 @@
   COMP_WORDS=("--python" "3")
   breeze_complete::_comp_breeze
 
-  assert_equal "${COMPREPLY[*]}" "3.7 3.8 3.9 3.6"
+  assert_equal "${COMPREPLY[*]}" "3.7 3.8 3.9"
 }
 
 @test "Test autocomplete build-" {

From 590f28c6145b8c7cfc10bcaad2ec1506d6b2f7fa Mon Sep 17 00:00:00 2001
From: Jarek Potiuk <potiuk@apache.org>
Date: Thu, 23 Dec 2021 10:18:36 +0100
Subject: [PATCH 2/2] Update setup.py

Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 5ca559201c5e0..e97e5804814bd 100644
--- a/setup.py
+++ b/setup.py
@@ -238,7 +238,7 @@ def write_version(filename: str = os.path.join(*[my_dir, "airflow", "git_version
 ]
 dask = [
     'cloudpickle>=1.4.1, <1.5.0',
-    'dask>=2.9.0, <2021.6.1;python_version>="3.7"',  # dask 2021.6.1 does not work with `distributed`
+    'dask>=2.9.0, <2021.6.1',  # dask 2021.6.1 does not work with `distributed`
     'distributed>=2.11.1, <2.20',
 ]
 databricks = [
