Skip to content

Commit

Permalink
Remove unnecessary python 3.6 conditionals
Browse files Browse the repository at this point in the history
Since Python 3.7 is now the lowest supported version, we no longer need
to have conditionals to support 3.6.
  • Loading branch information
jedcunningham committed Dec 29, 2021
1 parent 8acfe8d commit 63bdea2
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 74 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ARG AIRFLOW_VERSION="2.2.0.dev0"
ARG AIRFLOW_IMAGE_REPOSITORY="https://github.com/apache/airflow"

# By increasing this number we can do force build of all dependencies
ARG DEPENDENCIES_EPOCH_NUMBER="6"
ARG DEPENDENCIES_EPOCH_NUMBER="7"

# Make sure noninteractive debian install is used and language variables set
ENV PYTHON_BASE_IMAGE=${PYTHON_BASE_IMAGE} AIRFLOW_VERSION=${AIRFLOW_VERSION} \
Expand Down
10 changes: 1 addition & 9 deletions airflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

__version__ = version.version

__all__ = ['__version__', 'login', 'DAG', 'PY36', 'PY37', 'PY38', 'PY39', 'PY310']
__all__ = ['__version__', 'login', 'DAG', 'PY38', 'PY39', 'PY310']

# Make `airflow` an namespace package, supporting installing
# airflow.providers.* in different locations (i.e. one in site, and one in user
Expand All @@ -47,8 +47,6 @@

login: Optional[Callable] = None

PY36 = sys.version_info >= (3, 6)
PY37 = sys.version_info >= (3, 7)
PY38 = sys.version_info >= (3, 8)
PY39 = sys.version_info >= (3, 9)
PY310 = sys.version_info >= (3, 10)
Expand Down Expand Up @@ -89,9 +87,3 @@ def __getattr__(name):
if STATICA_HACK: # pragma: no cover
from airflow.models.dag import DAG
from airflow.exceptions import AirflowException


if not PY37:
from pep562 import Pep562

Pep562(__name__)
5 changes: 1 addition & 4 deletions airflow/cli/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from functools import lru_cache
from typing import Callable, Dict, Iterable, List, NamedTuple, Optional, Union

from airflow import PY37, settings
from airflow import settings
from airflow.cli.commands.legacy_commands import check_legacy_command
from airflow.configuration import conf
from airflow.exceptions import AirflowException
Expand Down Expand Up @@ -82,9 +82,6 @@ def _check_value(self, action, value):
"To do it, run: pip install 'apache-airflow[cncf.kubernetes]'"
)
raise ArgumentError(action, message)
if action.dest == 'subcommand' and value == 'triggerer':
if not PY37:
raise ArgumentError(action, 'triggerer subcommand only works with Python 3.7+')

if action.choices is not None and value not in action.choices:
check_legacy_command(action, value)
Expand Down
7 changes: 0 additions & 7 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,10 +1124,3 @@ def __getattr__(name):
conf = initialize_config()
secrets_backend_list = initialize_secrets_backends()
conf.validate()


PY37 = sys.version_info >= (3, 7)
if not PY37:
from pep562 import Pep562

Pep562(__name__)
20 changes: 0 additions & 20 deletions airflow/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# under the License.
#
import logging
import sys
import warnings
from logging.config import dictConfig

Expand Down Expand Up @@ -103,22 +102,3 @@ def _get_handler(name):
f"Configured task_log_reader {task_log_reader!r} was not a handler of "
f"the 'airflow.task' logger."
)


if sys.version_info < (3, 7):
# Python 3.7 added this via https://bugs.python.org/issue30520 -- but Python 3.6 doesn't have this
# support.
import copyreg

def _reduce_Logger(logger):
if logging.getLogger(logger.name) is not logger:
import pickle

raise pickle.PicklingError('logger cannot be pickled')
return logging.getLogger, (logger.name,)

def _reduce_RootLogger(logger):
return logging.getLogger, ()

copyreg.pickle(logging.Logger, _reduce_Logger)
copyreg.pickle(logging.RootLogger, _reduce_RootLogger)
8 changes: 0 additions & 8 deletions airflow/migrations/db_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# specific language governing permissions and limitations
# under the License.
#
import sys

import sqlalchemy as sa
from alembic import context
from lazy_object_proxy import Proxy
Expand Down Expand Up @@ -100,9 +98,3 @@ def lazy_load():
return Proxy(lazy_load)

raise AttributeError(f"module {__name__} has no attribute {name}")


if sys.version_info < (3, 7):
from pep562 import Pep562

Pep562(__name__)
7 changes: 0 additions & 7 deletions airflow/utils/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
And then be used directly in place of the normal python module.
"""
import sys
from typing import TYPE_CHECKING, Any, BinaryIO, TextIO, Union, cast

if TYPE_CHECKING:
Expand Down Expand Up @@ -68,9 +67,3 @@ def __getattr__(name):
getattr(yaml, "CFullLoader", yaml.FullLoader)

return getattr(yaml, name)


if sys.version_info < (3, 7):
from pep562 import Pep562

Pep562(__name__)
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ install_requires =
openapi-spec-validator>=0.2.4
packaging>=14.0
pendulum~=2.0
pep562~=1.0;python_version<"3.7"
psutil>=4.2.0, <6.0.0
pygments>=2.0.1, <3.0
pyjwt<3
Expand Down
4 changes: 0 additions & 4 deletions tests/cli/commands/test_triggerer_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
import unittest
from unittest import mock

import pytest

from airflow import PY37
from airflow.cli import cli_parser
from airflow.cli.commands import triggerer_command

Expand All @@ -34,7 +31,6 @@ class TestTriggererCommand(unittest.TestCase):
def setUpClass(cls):
cls.parser = cli_parser.get_parser()

@pytest.mark.skipif(not PY37, reason="triggerer subcommand only works with Python 3.7+")
@mock.patch("airflow.cli.commands.triggerer_command.TriggererJob")
def test_capacity_argument(
self,
Expand Down
11 changes: 0 additions & 11 deletions tests/jobs/test_triggerer_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# under the License.

import datetime
import sys
import time

import pytest
Expand Down Expand Up @@ -49,7 +48,6 @@ def session():
yield session


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_is_alive():
"""Checks the heartbeat logic"""
# Current time
Expand All @@ -70,7 +68,6 @@ def test_is_alive():
assert not triggerer_job.is_alive(), "Completed jobs even with recent heartbeat should not be alive"


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_is_needed(session):
"""Checks the triggerer-is-needed logic"""
# No triggers, no need
Expand All @@ -85,7 +82,6 @@ def test_is_needed(session):
assert triggerer_job.is_needed() is True


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_capacity_decode():
"""
Tests that TriggererJob correctly sets capacity to a valid value passed in as a CLI arg,
Expand All @@ -112,7 +108,6 @@ def test_capacity_decode():
TriggererJob(capacity=input_str)


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_trigger_lifecycle(session):
"""
Checks that the triggerer will correctly see a new Trigger in the database
Expand Down Expand Up @@ -159,7 +154,6 @@ def test_trigger_lifecycle(session):
job.runner.stop = True


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_trigger_from_dead_triggerer(session):
"""
Checks that the triggerer will correctly claim a Trigger that is assigned to a
Expand All @@ -179,7 +173,6 @@ def test_trigger_from_dead_triggerer(session):
assert [x for x, y in job.runner.to_create] == [1]


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_trigger_from_expired_triggerer(session):
"""
Checks that the triggerer will correctly claim a Trigger that is assigned to a
Expand All @@ -206,7 +199,6 @@ def test_trigger_from_expired_triggerer(session):
assert [x for x, y in job.runner.to_create] == [1]


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_trigger_firing(session):
"""
Checks that when a trigger fires, it correctly makes it into the
Expand Down Expand Up @@ -238,7 +230,6 @@ def test_trigger_firing(session):
job.runner.stop = True


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_trigger_failing(session):
"""
Checks that when a trigger fails, it correctly makes it into the
Expand Down Expand Up @@ -270,7 +261,6 @@ def test_trigger_failing(session):
job.runner.stop = True


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_trigger_cleanup(session):
"""
Checks that the triggerer will correctly clean up triggers that do not
Expand All @@ -290,7 +280,6 @@ def test_trigger_cleanup(session):
assert session.query(Trigger).count() == 0


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No triggerer on 3.6")
def test_invalid_trigger(session, dag_maker):
"""
Checks that the triggerer will correctly fail task instances that depend on
Expand Down
2 changes: 0 additions & 2 deletions tests/triggers/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import asyncio
import datetime
import sys

import pendulum
import pytest
Expand Down Expand Up @@ -62,7 +61,6 @@ def test_timedelta_trigger_serialization():
assert -2 < (kwargs["moment"] - expected_moment).total_seconds() < 2


@pytest.mark.skipif(sys.version_info.minor <= 6 and sys.version_info.major <= 3, reason="No async on 3.6")
@pytest.mark.asyncio
async def test_datetime_trigger_timing():
"""
Expand Down

0 comments on commit 63bdea2

Please sign in to comment.