From a6f6d84fc31f20e2f96d9255edd563656b0b1a47 Mon Sep 17 00:00:00 2001 From: monkut Date: Sat, 16 Jul 2022 15:03:25 +0900 Subject: [PATCH] :fire: remove `future` (past) requirements basestring usage, replacing with isinstance(x, str) :wrench: change usage of utcnow() -> datetime.datetime.now(datetime.timezone.utc) --- zappa/cli.py | 6 +----- zappa/utilities.py | 7 ++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/zappa/cli.py b/zappa/cli.py index 5dc2c3cc5..305e74e30 100755 --- a/zappa/cli.py +++ b/zappa/cli.py @@ -1,6 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - """ Zappa CLI @@ -38,7 +35,6 @@ from click.exceptions import ClickException from click.globals import push_context from dateutil import parser -from past.builtins import basestring from .core import API_GATEWAY_REGIONS, Zappa from .utilities import ( @@ -1635,7 +1631,7 @@ def check_environment(self, environment): non_strings = [] for (k, v) in environment.items(): - if not isinstance(v, basestring): + if not isinstance(v, str): non_strings.append(k) if non_strings: raise ValueError("The following environment variables are not strings: {}".format(", ".join(non_strings))) diff --git a/zappa/utilities.py b/zappa/utilities.py index 1bf4612d5..72ad9f0f7 100644 --- a/zappa/utilities.py +++ b/zappa/utilities.py @@ -13,7 +13,6 @@ import botocore import durationpy -from past.builtins import basestring LOG = logging.getLogger(__name__) @@ -105,7 +104,7 @@ def string_to_timestamp(timestring): # Uses an extended version of Go's duration string. try: delta = durationpy.from_str(timestring) - past = datetime.datetime.utcnow() - delta + past = datetime.datetime.now(datetime.timezone.utc) - delta ts = calendar.timegm(past.timetuple()) return ts except Exception: @@ -113,8 +112,6 @@ def string_to_timestamp(timestring): if ts: return ts - # else: - # print("Unable to parse timestring.") return 0 @@ -494,7 +491,7 @@ def validate_name(name, maxlen=80): Return: the name Raise: InvalidAwsLambdaName, if the name is invalid. """ - if not isinstance(name, basestring): + if not isinstance(name, str): msg = "Name must be of type string" raise InvalidAwsLambdaName(msg) if len(name) > maxlen: