You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/12/19 10:49:14 UTC

[airflow] branch main updated: Fix mypy errors in aws/sensors (#20402)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 404cd2e  Fix mypy errors in aws/sensors (#20402)
404cd2e is described below

commit 404cd2eb69605c3b960c7c6936cb8b342acb6f64
Author: Kanthi <su...@gmail.com>
AuthorDate: Sun Dec 19 05:48:46 2021 -0500

    Fix mypy errors in aws/sensors (#20402)
---
 airflow/providers/amazon/aws/sensors/emr.py | 6 +++---
 airflow/providers/amazon/aws/sensors/s3.py  | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/airflow/providers/amazon/aws/sensors/emr.py b/airflow/providers/amazon/aws/sensors/emr.py
index 6a7fd77..dce7733 100644
--- a/airflow/providers/amazon/aws/sensors/emr.py
+++ b/airflow/providers/amazon/aws/sensors/emr.py
@@ -15,12 +15,12 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-
+import sys
 from typing import Any, Dict, Iterable, Optional
 
-try:
+if sys.version_info >= (3, 8):
     from functools import cached_property
-except ImportError:
+else:
     from cached_property import cached_property
 
 from airflow.exceptions import AirflowException
diff --git a/airflow/providers/amazon/aws/sensors/s3.py b/airflow/providers/amazon/aws/sensors/s3.py
index 6113d4b..3969b19 100644
--- a/airflow/providers/amazon/aws/sensors/s3.py
+++ b/airflow/providers/amazon/aws/sensors/s3.py
@@ -19,13 +19,14 @@
 
 import os
 import re
+import sys
 from datetime import datetime
 from typing import Any, Callable, Dict, List, Optional, Set, Union
 from urllib.parse import urlparse
 
-try:
+if sys.version_info >= (3, 8):
     from functools import cached_property
-except ImportError:
+else:
     from cached_property import cached_property
 
 from airflow.exceptions import AirflowException
@@ -191,7 +192,7 @@ class S3KeySizeSensor(S3KeySensor):
         response = paginator.paginate(
             Bucket=self.bucket_name, Prefix=prefix, Delimiter=delimiter, PaginationConfig=config
         )
-        keys = []
+        keys: List = []
         for page in response:
             if 'Contents' in page:
                 _temp = [k for k in page['Contents'] if isinstance(k.get('Size', None), (int, float))]