Skip to content

Commit

Permalink
🔥 remove future (past) requirements basestring usage, replacing wit…
Browse files Browse the repository at this point in the history
…h isinstance(x, str)

🔧 change usage of utcnow() -> datetime.datetime.now(datetime.timezone.utc)
  • Loading branch information
monkut committed Jul 16, 2022
1 parent 34b5060 commit a6f6d84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 1 addition & 5 deletions zappa/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Zappa CLI
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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)))
Expand Down
7 changes: 2 additions & 5 deletions zappa/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import botocore
import durationpy
from past.builtins import basestring

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -105,16 +104,14 @@ 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:
pass

if ts:
return ts
# else:
# print("Unable to parse timestring.")
return 0


Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit a6f6d84

Please sign in to comment.