diff --git a/acceptreject.py b/acceptreject.py
index 6ddd54b00..0e100173f 100644
--- a/acceptreject.py
+++ b/acceptreject.py
@@ -110,8 +110,7 @@ def _create_accept_reject(federation_list: [],
'object': object_json
}
if cc_url:
- if len(cc_url) > 0:
- new_accept['cc'] = [cc_url]
+ new_accept['cc'] = [cc_url]
return new_accept
diff --git a/announce.py b/announce.py
index 865aab407..5a49cc6f7 100644
--- a/announce.py
+++ b/announce.py
@@ -206,8 +206,7 @@ def create_announce(session, base_dir: str, federation_list: [],
'type': 'Announce'
}
if cc_url:
- if len(cc_url) > 0:
- new_announce['cc'] = [cc_url]
+ new_announce['cc'] = [cc_url]
if save_to_file:
outbox_dir = create_outbox_dir(nickname, domain, base_dir)
filename = \
diff --git a/daemon_post_login.py b/daemon_post_login.py
index e6bf37b80..76bf4524c 100644
--- a/daemon_post_login.py
+++ b/daemon_post_login.py
@@ -234,7 +234,7 @@ def post_login_screen(self, calling_domain: str, cookie: str,
login_str += login_prm + '='
else:
len_str = login_prm.split('&')[0]
- if len(len_str) > 0:
+ if len_str:
login_str += login_prm + '*'
len_str = ''
if '&' in login_prm:
diff --git a/like.py b/like.py
index 15e1b8f39..09fdbe784 100644
--- a/like.py
+++ b/like.py
@@ -104,8 +104,7 @@ def _create_like(recent_posts_cache: {},
'object': object_url
}
if cc_list:
- if len(cc_list) > 0:
- new_like_json['cc'] = cc_list
+ new_like_json['cc'] = cc_list
# Extract the domain and nickname from a statuses link
liked_post_nickname = None
diff --git a/pgp.py b/pgp.py
index aa6907799..7a392a31e 100644
--- a/pgp.py
+++ b/pgp.py
@@ -917,7 +917,7 @@ def actor_to_vcard(actor: {}, domain: str, translate: {}) -> str:
vcard_str += \
'EXPERTISE;LEVEL=' + level_str + ':' + skill_name + '\n'
if actor.get('hasOccupation'):
- if len(actor['hasOccupation']) > 0:
+ if actor['hasOccupation']:
if actor['hasOccupation'][0].get('name'):
vcard_str += \
'ROLE:' + \
@@ -1048,7 +1048,7 @@ def actor_to_vcard_xml(actor: {}, domain: str, translate: {}) -> str:
'' + \
'' + pgp_key_encoded + '\n'
if actor.get('hasOccupation'):
- if len(actor['hasOccupation']) > 0:
+ if actor['hasOccupation']:
if actor['hasOccupation'][0].get('name'):
vcard_str += \
' ' + \
diff --git a/posts.py b/posts.py
index 69037225a..3bdea596c 100644
--- a/posts.py
+++ b/posts.py
@@ -5692,7 +5692,7 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
print('EX: archive_posts_for_person unable to read ' +
index_filename + ' ' + str(ex))
# save the new index file
- if len(new_index) > 0:
+ if new_index:
try:
with open(index_filename, 'w+',
encoding='utf-8') as fp_index:
diff --git a/pyjsonld.py b/pyjsonld.py
index 8e8d2b487..909a8c769 100644
--- a/pyjsonld.py
+++ b/pyjsonld.py
@@ -567,7 +567,7 @@ def prepend_base(base, iri):
# directory from base
if rel.path != '':
path = path[0:path.rfind('/') + 1]
- if len(path) > 0 and not path.endswith('/'):
+ if path and not path.endswith('/'):
path += '/'
path += rel.path
@@ -779,7 +779,7 @@ class JsonLdProcessor(object):
tmp = ctx
ctx = []
for v in tmp:
- if not _is_object(v) or len(v) > 0:
+ if not _is_object(v) or v:
ctx.append(v)
# remove array if only one context
@@ -1265,7 +1265,7 @@ class JsonLdProcessor(object):
"""
if property in subject:
value = subject[property]
- return not _is_array(value) or len(value) > 0
+ return not _is_array(value) or value
return False
@staticmethod
diff --git a/webapp_post.py b/webapp_post.py
index 35028096f..e1aa852bd 100644
--- a/webapp_post.py
+++ b/webapp_post.py
@@ -190,7 +190,7 @@ def get_instance_software(base_dir: str, session,
nodeinfo_url = None
if nodeinfo1_json.get('links'):
if isinstance(nodeinfo1_json['links'], list):
- if len(nodeinfo1_json['links']) > 0:
+ if nodeinfo1_json['links']:
if nodeinfo1_json['links'][0].get('href'):
href = nodeinfo1_json['links'][0]['href']
if isinstance(href, str):
diff --git a/webapp_profile.py b/webapp_profile.py
index 7751e6bec..a0b3e8f6a 100644
--- a/webapp_profile.py
+++ b/webapp_profile.py
@@ -1336,12 +1336,13 @@ def html_profile(signing_priv_key_pem: str,
with open(follow_requests_filename, 'r',
encoding='utf-8') as fp_foll:
for line in fp_foll:
- if len(line) > 0:
- follow_approvals = True
- followers_button = 'buttonhighlighted'
- if selected == 'followers':
- followers_button = 'buttonselectedhighlighted'
- break
+ if not line:
+ continue
+ follow_approvals = True
+ followers_button = 'buttonhighlighted'
+ if selected == 'followers':
+ followers_button = 'buttonselectedhighlighted'
+ break
except OSError as exc:
print('EX: html_profile unable to read ' +
follow_requests_filename + ' ' + str(exc))
@@ -1352,59 +1353,60 @@ def html_profile(signing_priv_key_pem: str,
with open(follow_requests_filename, 'r',
encoding='utf-8') as fp_req:
for follower_handle in fp_req:
- if len(follower_handle) > 0:
- follower_handle = \
- remove_eol(follower_handle)
- if '://' in follower_handle:
- follower_actor = follower_handle
- else:
- nick = follower_handle.split('@')[0]
- dom = follower_handle.split('@')[1]
- follower_actor = \
- local_actor_url(http_prefix, nick, dom)
+ if not follower_handle:
+ continue
+ follower_handle = \
+ remove_eol(follower_handle)
+ if '://' in follower_handle:
+ follower_actor = follower_handle
+ else:
+ nick = follower_handle.split('@')[0]
+ dom = follower_handle.split('@')[1]
+ follower_actor = \
+ local_actor_url(http_prefix, nick, dom)
- # is this a new domain?
- # if so then append a new instance indicator
- follower_domain, _ = \
- get_domain_from_actor(follower_actor)
- new_follower_domain = ''
- if follower_domain not in curr_follower_domains:
- new_follower_domain = ' ✨'
+ # is this a new domain?
+ # if so then append a new instance indicator
+ follower_domain, _ = \
+ get_domain_from_actor(follower_actor)
+ new_follower_domain = ''
+ if follower_domain not in curr_follower_domains:
+ new_follower_domain = ' ✨'
- # Show the handle of the potential follower
- # being approved, linking to search on that handle
- base_path = '/users/' + nickname
- follow_approvals_section += \
- '
\n' + \
- ' \n'
+ # Show the handle of the potential follower
+ # being approved, linking to search on that handle
+ base_path = '/users/' + nickname
+ follow_approvals_section += \
+ '