Skip to content

Commit

Permalink
Python 3.8 needed SyntaxWarning fixes - as annoying as that was!
Browse files Browse the repository at this point in the history
  • Loading branch information
mahtin committed Jan 14, 2020
1 parent d76dd70 commit b5cd481
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CloudFlare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Cloudflare v4 API"""
from __future__ import absolute_import

__version__ = '2.4.0'
__version__ = '2.4.1'

from .cloudflare import CloudFlare

Expand Down
6 changes: 3 additions & 3 deletions CloudFlare/cloudflare.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,11 +836,11 @@ def __init__(self, email=None, token=None, certtoken=None, debug=False, raw=Fals
if certtoken is None:
certtoken = conf_certtoken

if email is '':
if email == '':
email = None
if token is '':
if token == '':
token = None
if certtoken is '':
if certtoken == '':
certtoken = None
self._base = self._v4base(email, token, certtoken, base_url, debug, raw, use_sessions)

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,8 @@ As of January 2020 the code is Python3 clean.

As of January 2020 the code is shipped up to pypi with Python2 support removed.

As of January 2020 the code is Python3.8 clean. The new `SyntaxWarning` messages (i.e. `SyntaxWarning: "is" with a literal. Did you mean "=="?`) meant minor edits were needed.

## Credit

This is based on work by [Felix Wong (gnowxilef)](https://github.com/gnowxilef) found [here](https://github.com/cloudflare-api/python-cloudflare-v4).
Expand Down
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,11 @@ As of January 2020 the code is Python3 clean.
As of January 2020 the code is shipped up to pypi with Python2 support
removed.

As of January 2020 the code is Python3.8 clean. The new
``SyntaxWarning`` messages (i.e.
``SyntaxWarning: "is" with a literal. Did you mean "=="?``) meant minor
edits were needed.

Credit
------

Expand Down
20 changes: 10 additions & 10 deletions cli4/cli4.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,27 @@ def run_command(cf, method, command, params=None, content=None, files=None):
identifier2 = [None]
for i2 in identifier2:
try:
if method is 'GET':
if method == 'GET':
r = m.get(identifier1=identifier1,
identifier2=i2,
identifier3=identifier3,
params=params)
elif method is 'PATCH':
elif method == 'PATCH':
r = m.patch(identifier1=identifier1,
identifier2=i2,
identifier3=identifier3,
data=params)
elif method is 'POST':
elif method == 'POST':
r = m.post(identifier1=identifier1,
identifier2=i2,
identifier3=identifier3,
data=params, files=files)
elif method is 'PUT':
elif method == 'PUT':
r = m.put(identifier1=identifier1,
identifier2=i2,
identifier3=identifier3,
data=params)
elif method is 'DELETE':
elif method == 'DELETE':
r = m.delete(identifier1=identifier1,
identifier2=i2,
identifier3=identifier3,
Expand Down Expand Up @@ -298,13 +298,13 @@ def do_it(args):
value = False
elif value_string == '' or value_string.lower() == 'none':
value = None
elif value_string[0] is '=' and value_string[1:] == '':
elif value_string[0] == '=' and value_string[1:] == '':
exit('cli4: %s== - no number value passed' % (tag_string))
elif value_string[0] is '=' and digits_only.match(value_string[1:]):
elif value_string[0] == '=' and digits_only.match(value_string[1:]):
value = int(value_string[1:])
elif value_string[0] is '=' and floats_only.match(value_string[1:]):
elif value_string[0] == '=' and floats_only.match(value_string[1:]):
value = float(value_string[1:])
elif value_string[0] is '=':
elif value_string[0] == '=':
exit('cli4: %s== - invalid number value passed' % (tag_string))
elif value_string[0] in '[{' and value_string[-1] in '}]':
# a json structure - used in pagerules
Expand All @@ -315,7 +315,7 @@ def do_it(args):
value = yaml.safe_load(value_string)
except ValueError:
exit('cli4: %s="%s" - can\'t parse json value' % (tag_string, value_string))
elif value_string[0] is '@':
elif value_string[0] == '@':
# a file to be uploaded - used in dns_records/import - only via POST
filename = value_string[1:]
if method != 'POST':
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def main():
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
'Programming Language :: Python :: 3.8'
]
)

Expand Down

0 comments on commit b5cd481

Please sign in to comment.