Skip to content

Commit

Permalink
Remove unnecessary python 3.6 conditionals (#20549)
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 authored Apr 10, 2022
1 parent 1007828 commit 81bbb55
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 71 deletions.
6 changes: 0 additions & 6 deletions airflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,3 @@ def __getattr__(name):
from airflow.models.dag import DAG
from airflow.models.xcom_arg import XComArg
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 @@ -28,7 +28,7 @@

import lazy_object_proxy

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 @@ -97,9 +97,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 @@ -1291,10 +1291,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 @@ -143,7 +143,6 @@ install_requires =
marshmallow-oneofschema>=2.0.1
packaging>=14.0
pendulum>=2.0
pep562>=1.0;python_version<"3.7"
pluggy>=1.0
psutil>=4.2.0
pygments>=2.0.1
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
12 changes: 0 additions & 12 deletions tests/jobs/test_triggerer_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import asyncio
import datetime
import sys
import time
from threading import Thread

Expand Down Expand Up @@ -73,7 +72,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 @@ -94,7 +92,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 @@ -109,7 +106,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 @@ -136,7 +132,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 @@ -183,7 +178,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_create_race_condition_18392(session, tmp_path):
"""
This verifies the resolution of race condition documented in github issue #18392.
Expand Down Expand Up @@ -289,7 +283,6 @@ def handle_events(self):
assert len(instances) == 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_dead_triggerer(session):
"""
Checks that the triggerer will correctly claim a Trigger that is assigned to a
Expand All @@ -309,7 +302,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 @@ -336,7 +328,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 @@ -368,7 +359,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 @@ -404,7 +394,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 @@ -424,7 +413,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 81bbb55

Please sign in to comment.