aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2022-11-21 20:17:18 +0200
committerGitHub <[email protected]>2022-11-21 20:17:18 +0200
commit943782afc394f52377223fb6b777946d5b2148ff (patch)
tree7fd8ad2031c281ac2a7cbc297fb20edd2fa4152e
parent98760f650bcaafedead3f0b6e2b0c594ab857338 (diff)
parentf04d57acbc5ef639c0dc70fde800cf5c24d0b967 (diff)
downloadmastodon.py-943782afc394f52377223fb6b777946d5b2148ff.tar.gz
Merge pull request #269 from eumiro/none_identity
Refactor: use is for None/True/False
-rw-r--r--mastodon/Mastodon.py269
-rw-r--r--mastodon/streaming.py14
-rw-r--r--tests/test_account.py2
-rw-r--r--tests/test_bookmarks.py6
-rw-r--r--tests/test_constructor.py6
-rw-r--r--tests/test_filters.py14
-rw-r--r--tests/test_hooks.py2
-rw-r--r--tests/test_instance.py2
-rw-r--r--tests/test_media.py4
-rw-r--r--tests/test_notifications.py2
-rw-r--r--tests/test_push.py16
-rw-r--r--tests/test_streaming.py8
-rw-r--r--tests/test_timeline.py4
13 files changed, 173 insertions, 176 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 70aac20..72eb727 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -378,7 +378,7 @@ class Mastodon:
378 If no other `User-Agent` is specified, "mastodonpy" will be used. 378 If no other `User-Agent` is specified, "mastodonpy" will be used.
379 """ 379 """
380 self.api_base_url = None 380 self.api_base_url = None
381 if not api_base_url is None: 381 if api_base_url is not None:
382 self.api_base_url = Mastodon.__protocolize(api_base_url) 382 self.api_base_url = Mastodon.__protocolize(api_base_url)
383 383
384 self.client_id = client_id 384 self.client_id = client_id
@@ -419,7 +419,7 @@ class Mastodon:
419 self.client_secret = secret_file.readline().rstrip() 419 self.client_secret = secret_file.readline().rstrip()
420 420
421 try_base_url = secret_file.readline().rstrip() 421 try_base_url = secret_file.readline().rstrip()
422 if (not try_base_url is None) and len(try_base_url) != 0: 422 if try_base_url is not None and len(try_base_url) != 0:
423 try_base_url = Mastodon.__protocolize(try_base_url) 423 try_base_url = Mastodon.__protocolize(try_base_url)
424 if not (self.api_base_url is None or try_base_url == self.api_base_url): 424 if not (self.api_base_url is None or try_base_url == self.api_base_url):
425 raise MastodonIllegalArgumentError( 425 raise MastodonIllegalArgumentError(
@@ -440,7 +440,7 @@ class Mastodon:
440 self.access_token = token_file.readline().rstrip() 440 self.access_token = token_file.readline().rstrip()
441 441
442 try_base_url = token_file.readline().rstrip() 442 try_base_url = token_file.readline().rstrip()
443 if (not try_base_url is None) and len(try_base_url) != 0: 443 if try_base_url is not None and len(try_base_url) != 0:
444 try_base_url = Mastodon.__protocolize(try_base_url) 444 try_base_url = Mastodon.__protocolize(try_base_url)
445 if not (self.api_base_url is None or try_base_url == self.api_base_url): 445 if not (self.api_base_url is None or try_base_url == self.api_base_url):
446 raise MastodonIllegalArgumentError( 446 raise MastodonIllegalArgumentError(
@@ -457,7 +457,7 @@ class Mastodon:
457 self.version_check_worked = None 457 self.version_check_worked = None
458 458
459 # Versioning 459 # Versioning
460 if mastodon_version == None and self.version_check_mode != 'none': 460 if mastodon_version is None and self.version_check_mode != 'none':
461 self.retrieve_mastodon_version() 461 self.retrieve_mastodon_version()
462 elif self.version_check_mode != 'none': 462 elif self.version_check_mode != 'none':
463 try: 463 try:
@@ -632,7 +632,7 @@ class Mastodon:
632 self.__logged_in_id = None 632 self.__logged_in_id = None
633 633
634 # Retry version check if needed (might be required in limited federation mode) 634 # Retry version check if needed (might be required in limited federation mode)
635 if self.version_check_worked == False: 635 if not self.version_check_worked:
636 self.retrieve_mastodon_version() 636 self.retrieve_mastodon_version()
637 637
638 return response['access_token'] 638 return response['access_token']
@@ -698,7 +698,7 @@ class Mastodon:
698 params['client_id'] = self.client_id 698 params['client_id'] = self.client_id
699 params['client_secret'] = self.client_secret 699 params['client_secret'] = self.client_secret
700 700
701 if agreement == False: 701 if not agreement:
702 del params['agreement'] 702 del params['agreement']
703 703
704 # Step 1: Get a user-free token via oauth 704 # Step 1: Get a user-free token via oauth
@@ -865,24 +865,24 @@ class Mastodon:
865 865
866 Returns a list of `toot dicts`_. 866 Returns a list of `toot dicts`_.
867 """ 867 """
868 if max_id != None: 868 if max_id is not None:
869 max_id = self.__unpack_id(max_id, dateconv=True) 869 max_id = self.__unpack_id(max_id, dateconv=True)
870 870
871 if min_id != None: 871 if min_id is not None:
872 min_id = self.__unpack_id(min_id, dateconv=True) 872 min_id = self.__unpack_id(min_id, dateconv=True)
873 873
874 if since_id != None: 874 if since_id is not None:
875 since_id = self.__unpack_id(since_id, dateconv=True) 875 since_id = self.__unpack_id(since_id, dateconv=True)
876 876
877 params_initial = locals() 877 params_initial = locals()
878 878
879 if local == False: 879 if not local:
880 del params_initial['local'] 880 del params_initial['local']
881 881
882 if remote == False: 882 if not remote:
883 del params_initial['remote'] 883 del params_initial['remote']
884 884
885 if only_media == False: 885 if not only_media:
886 del params_initial['only_media'] 886 del params_initial['only_media']
887 887
888 if timeline == "local": 888 if timeline == "local":
@@ -950,13 +950,13 @@ class Mastodon:
950 950
951 Returns a list of `conversation dicts`_. 951 Returns a list of `conversation dicts`_.
952 """ 952 """
953 if max_id != None: 953 if max_id is not None:
954 max_id = self.__unpack_id(max_id, dateconv=True) 954 max_id = self.__unpack_id(max_id, dateconv=True)
955 955
956 if min_id != None: 956 if min_id is not None:
957 min_id = self.__unpack_id(min_id, dateconv=True) 957 min_id = self.__unpack_id(min_id, dateconv=True)
958 958
959 if since_id != None: 959 if since_id is not None:
960 since_id = self.__unpack_id(since_id, dateconv=True) 960 since_id = self.__unpack_id(since_id, dateconv=True)
961 961
962 params = self.__generate_params(locals()) 962 params = self.__generate_params(locals())
@@ -1093,8 +1093,8 @@ class Mastodon:
1093 1093
1094 Returns a list of `notification dicts`_. 1094 Returns a list of `notification dicts`_.
1095 """ 1095 """
1096 if not mentions_only is None: 1096 if mentions_only is not None:
1097 if not exclude_types is None: 1097 if exclude_types is not None:
1098 if mentions_only: 1098 if mentions_only:
1099 exclude_types = ["follow", "favourite", 1099 exclude_types = ["follow", "favourite",
1100 "reblog", "poll", "follow_request"] 1100 "reblog", "poll", "follow_request"]
@@ -1103,16 +1103,16 @@ class Mastodon:
1103 'Cannot specify exclude_types when mentions_only is present') 1103 'Cannot specify exclude_types when mentions_only is present')
1104 del mentions_only 1104 del mentions_only
1105 1105
1106 if max_id != None: 1106 if max_id is not None:
1107 max_id = self.__unpack_id(max_id, dateconv=True) 1107 max_id = self.__unpack_id(max_id, dateconv=True)
1108 1108
1109 if min_id != None: 1109 if min_id is not None:
1110 min_id = self.__unpack_id(min_id, dateconv=True) 1110 min_id = self.__unpack_id(min_id, dateconv=True)
1111 1111
1112 if since_id != None: 1112 if since_id is not None:
1113 since_id = self.__unpack_id(since_id, dateconv=True) 1113 since_id = self.__unpack_id(since_id, dateconv=True)
1114 1114
1115 if account_id != None: 1115 if account_id is not None:
1116 account_id = self.__unpack_id(account_id) 1116 account_id = self.__unpack_id(account_id)
1117 1117
1118 if id is None: 1118 if id is None:
@@ -1178,23 +1178,23 @@ class Mastodon:
1178 Returns a list of `toot dicts`_. 1178 Returns a list of `toot dicts`_.
1179 """ 1179 """
1180 id = self.__unpack_id(id) 1180 id = self.__unpack_id(id)
1181 if max_id != None: 1181 if max_id is not None:
1182 max_id = self.__unpack_id(max_id, dateconv=True) 1182 max_id = self.__unpack_id(max_id, dateconv=True)
1183 1183
1184 if min_id != None: 1184 if min_id is not None:
1185 min_id = self.__unpack_id(min_id, dateconv=True) 1185 min_id = self.__unpack_id(min_id, dateconv=True)
1186 1186
1187 if since_id != None: 1187 if since_id is not None:
1188 since_id = self.__unpack_id(since_id, dateconv=True) 1188 since_id = self.__unpack_id(since_id, dateconv=True)
1189 1189
1190 params = self.__generate_params(locals(), ['id']) 1190 params = self.__generate_params(locals(), ['id'])
1191 if pinned == False: 1191 if not pinned:
1192 del params["pinned"] 1192 del params["pinned"]
1193 if only_media == False: 1193 if not only_media:
1194 del params["only_media"] 1194 del params["only_media"]
1195 if exclude_replies == False: 1195 if not exclude_replies:
1196 del params["exclude_replies"] 1196 del params["exclude_replies"]
1197 if exclude_reblogs == False: 1197 if not exclude_reblogs:
1198 del params["exclude_reblogs"] 1198 del params["exclude_reblogs"]
1199 1199
1200 url = '/api/v1/accounts/{0}/statuses'.format(str(id)) 1200 url = '/api/v1/accounts/{0}/statuses'.format(str(id))
@@ -1208,13 +1208,13 @@ class Mastodon:
1208 Returns a list of `user dicts`_. 1208 Returns a list of `user dicts`_.
1209 """ 1209 """
1210 id = self.__unpack_id(id) 1210 id = self.__unpack_id(id)
1211 if max_id != None: 1211 if max_id is not None:
1212 max_id = self.__unpack_id(max_id, dateconv=True) 1212 max_id = self.__unpack_id(max_id, dateconv=True)
1213 1213
1214 if min_id != None: 1214 if min_id is not None:
1215 min_id = self.__unpack_id(min_id, dateconv=True) 1215 min_id = self.__unpack_id(min_id, dateconv=True)
1216 1216
1217 if since_id != None: 1217 if since_id is not None:
1218 since_id = self.__unpack_id(since_id, dateconv=True) 1218 since_id = self.__unpack_id(since_id, dateconv=True)
1219 1219
1220 params = self.__generate_params(locals(), ['id']) 1220 params = self.__generate_params(locals(), ['id'])
@@ -1229,13 +1229,13 @@ class Mastodon:
1229 Returns a list of `user dicts`_. 1229 Returns a list of `user dicts`_.
1230 """ 1230 """
1231 id = self.__unpack_id(id) 1231 id = self.__unpack_id(id)
1232 if max_id != None: 1232 if max_id is not None:
1233 max_id = self.__unpack_id(max_id, dateconv=True) 1233 max_id = self.__unpack_id(max_id, dateconv=True)
1234 1234
1235 if min_id != None: 1235 if min_id is not None:
1236 min_id = self.__unpack_id(min_id, dateconv=True) 1236 min_id = self.__unpack_id(min_id, dateconv=True)
1237 1237
1238 if since_id != None: 1238 if since_id is not None:
1239 since_id = self.__unpack_id(since_id, dateconv=True) 1239 since_id = self.__unpack_id(since_id, dateconv=True)
1240 1240
1241 params = self.__generate_params(locals(), ['id']) 1241 params = self.__generate_params(locals(), ['id'])
@@ -1359,7 +1359,7 @@ class Mastodon:
1359 continue 1359 continue
1360 1360
1361 filter_string = re.escape(keyword_filter["phrase"]) 1361 filter_string = re.escape(keyword_filter["phrase"])
1362 if keyword_filter["whole_word"] == True: 1362 if keyword_filter["whole_word"]:
1363 filter_string = "\\b" + filter_string + "\\b" 1363 filter_string = "\\b" + filter_string + "\\b"
1364 filter_strings.append(filter_string) 1364 filter_strings.append(filter_string)
1365 filter_re = re.compile("|".join(filter_strings), flags=re.IGNORECASE) 1365 filter_re = re.compile("|".join(filter_strings), flags=re.IGNORECASE)
@@ -1425,8 +1425,8 @@ class Mastodon:
1425 Internal Helper: Throw a MastodonVersionError if version is < 2.8.0 but parameters 1425 Internal Helper: Throw a MastodonVersionError if version is < 2.8.0 but parameters
1426 for search that are available only starting with 2.8.0 are specified. 1426 for search that are available only starting with 2.8.0 are specified.
1427 """ 1427 """
1428 if not account_id is None or not offset is None or not min_id is None or not max_id is None: 1428 if any(item is not None for item in (account_id, offset, min_id, max_id)):
1429 if self.verify_minimum_version("2.8.0", cached=True) == False: 1429 if not self.verify_minimum_version("2.8.0", cached=True):
1430 raise MastodonVersionError("Advanced search parameters require Mastodon 2.8.0+") 1430 raise MastodonVersionError("Advanced search parameters require Mastodon 2.8.0+")
1431 1431
1432 @api_version("1.1.0", "2.8.0", __DICT_VERSION_SEARCHRESULT) 1432 @api_version("1.1.0", "2.8.0", __DICT_VERSION_SEARCHRESULT)
@@ -1455,7 +1455,7 @@ class Mastodon:
1455 1455
1456 Returns a `search result dict`_, with tags as `hashtag dicts`_. 1456 Returns a `search result dict`_, with tags as `hashtag dicts`_.
1457 """ 1457 """
1458 if self.verify_minimum_version("2.4.1", cached=True) == True: 1458 if self.verify_minimum_version("2.4.1", cached=True):
1459 return self.search_v2(q, resolve=resolve, result_type=result_type, account_id=account_id, offset=offset, min_id=min_id, max_id=max_id) 1459 return self.search_v2(q, resolve=resolve, result_type=result_type, account_id=account_id, offset=offset, min_id=min_id, max_id=max_id)
1460 else: 1460 else:
1461 self.__ensure_search_params_acceptable( 1461 self.__ensure_search_params_acceptable(
@@ -1471,7 +1471,7 @@ class Mastodon:
1471 Returns a `search result dict`_. 1471 Returns a `search result dict`_.
1472 """ 1472 """
1473 params = self.__generate_params(locals()) 1473 params = self.__generate_params(locals())
1474 if resolve == False: 1474 if not resolve:
1475 del params['resolve'] 1475 del params['resolve']
1476 return self.__api_request('GET', '/api/v1/search', params) 1476 return self.__api_request('GET', '/api/v1/search', params)
1477 1477
@@ -1489,10 +1489,10 @@ class Mastodon:
1489 account_id, offset, min_id, max_id) 1489 account_id, offset, min_id, max_id)
1490 params = self.__generate_params(locals()) 1490 params = self.__generate_params(locals())
1491 1491
1492 if resolve == False: 1492 if not resolve:
1493 del params["resolve"] 1493 del params["resolve"]
1494 1494
1495 if exclude_unreviewed == False or not self.verify_minimum_version("3.0.0", cached=True): 1495 if not exclude_unreviewed or not self.verify_minimum_version("3.0.0", cached=True):
1496 del params["exclude_unreviewed"] 1496 del params["exclude_unreviewed"]
1497 1497
1498 if "result_type" in params: 1498 if "result_type" in params:
@@ -1554,13 +1554,13 @@ class Mastodon:
1554 """ 1554 """
1555 id = self.__unpack_id(id) 1555 id = self.__unpack_id(id)
1556 1556
1557 if max_id != None: 1557 if max_id is not None:
1558 max_id = self.__unpack_id(max_id, dateconv=True) 1558 max_id = self.__unpack_id(max_id, dateconv=True)
1559 1559
1560 if min_id != None: 1560 if min_id is not None:
1561 min_id = self.__unpack_id(min_id, dateconv=True) 1561 min_id = self.__unpack_id(min_id, dateconv=True)
1562 1562
1563 if since_id != None: 1563 if since_id is not None:
1564 since_id = self.__unpack_id(since_id, dateconv=True) 1564 since_id = self.__unpack_id(since_id, dateconv=True)
1565 1565
1566 params = self.__generate_params(locals(), ['id']) 1566 params = self.__generate_params(locals(), ['id'])
@@ -1576,13 +1576,13 @@ class Mastodon:
1576 1576
1577 Returns a list of `user dicts`_. 1577 Returns a list of `user dicts`_.
1578 """ 1578 """
1579 if max_id != None: 1579 if max_id is not None:
1580 max_id = self.__unpack_id(max_id, dateconv=True) 1580 max_id = self.__unpack_id(max_id, dateconv=True)
1581 1581
1582 if min_id != None: 1582 if min_id is not None:
1583 min_id = self.__unpack_id(min_id, dateconv=True) 1583 min_id = self.__unpack_id(min_id, dateconv=True)
1584 1584
1585 if since_id != None: 1585 if since_id is not None:
1586 since_id = self.__unpack_id(since_id, dateconv=True) 1586 since_id = self.__unpack_id(since_id, dateconv=True)
1587 1587
1588 params = self.__generate_params(locals()) 1588 params = self.__generate_params(locals())
@@ -1595,13 +1595,13 @@ class Mastodon:
1595 1595
1596 Returns a list of `user dicts`_. 1596 Returns a list of `user dicts`_.
1597 """ 1597 """
1598 if max_id != None: 1598 if max_id is not None:
1599 max_id = self.__unpack_id(max_id, dateconv=True) 1599 max_id = self.__unpack_id(max_id, dateconv=True)
1600 1600
1601 if min_id != None: 1601 if min_id is not None:
1602 min_id = self.__unpack_id(min_id, dateconv=True) 1602 min_id = self.__unpack_id(min_id, dateconv=True)
1603 1603
1604 if since_id != None: 1604 if since_id is not None:
1605 since_id = self.__unpack_id(since_id, dateconv=True) 1605 since_id = self.__unpack_id(since_id, dateconv=True)
1606 1606
1607 params = self.__generate_params(locals()) 1607 params = self.__generate_params(locals())
@@ -1632,13 +1632,13 @@ class Mastodon:
1632 1632
1633 Returns a list of `toot dicts`_. 1633 Returns a list of `toot dicts`_.
1634 """ 1634 """
1635 if max_id != None: 1635 if max_id is not None:
1636 max_id = self.__unpack_id(max_id, dateconv=True) 1636 max_id = self.__unpack_id(max_id, dateconv=True)
1637 1637
1638 if min_id != None: 1638 if min_id is not None:
1639 min_id = self.__unpack_id(min_id, dateconv=True) 1639 min_id = self.__unpack_id(min_id, dateconv=True)
1640 1640
1641 if since_id != None: 1641 if since_id is not None:
1642 since_id = self.__unpack_id(since_id, dateconv=True) 1642 since_id = self.__unpack_id(since_id, dateconv=True)
1643 1643
1644 params = self.__generate_params(locals()) 1644 params = self.__generate_params(locals())
@@ -1654,13 +1654,13 @@ class Mastodon:
1654 1654
1655 Returns a list of `user dicts`_. 1655 Returns a list of `user dicts`_.
1656 """ 1656 """
1657 if max_id != None: 1657 if max_id is not None:
1658 max_id = self.__unpack_id(max_id, dateconv=True) 1658 max_id = self.__unpack_id(max_id, dateconv=True)
1659 1659
1660 if min_id != None: 1660 if min_id is not None:
1661 min_id = self.__unpack_id(min_id, dateconv=True) 1661 min_id = self.__unpack_id(min_id, dateconv=True)
1662 1662
1663 if since_id != None: 1663 if since_id is not None:
1664 since_id = self.__unpack_id(since_id, dateconv=True) 1664 since_id = self.__unpack_id(since_id, dateconv=True)
1665 1665
1666 params = self.__generate_params(locals()) 1666 params = self.__generate_params(locals())
@@ -1676,13 +1676,13 @@ class Mastodon:
1676 1676
1677 Returns a list of blocked domain URLs (as strings, without protocol specifier). 1677 Returns a list of blocked domain URLs (as strings, without protocol specifier).
1678 """ 1678 """
1679 if max_id != None: 1679 if max_id is not None:
1680 max_id = self.__unpack_id(max_id, dateconv=True) 1680 max_id = self.__unpack_id(max_id, dateconv=True)
1681 1681
1682 if min_id != None: 1682 if min_id is not None:
1683 min_id = self.__unpack_id(min_id, dateconv=True) 1683 min_id = self.__unpack_id(min_id, dateconv=True)
1684 1684
1685 if since_id != None: 1685 if since_id is not None:
1686 since_id = self.__unpack_id(since_id, dateconv=True) 1686 since_id = self.__unpack_id(since_id, dateconv=True)
1687 1687
1688 params = self.__generate_params(locals()) 1688 params = self.__generate_params(locals())
@@ -1782,13 +1782,13 @@ class Mastodon:
1782 1782
1783 Returns a list of `toot dicts`_. 1783 Returns a list of `toot dicts`_.
1784 """ 1784 """
1785 if max_id != None: 1785 if max_id is not None:
1786 max_id = self.__unpack_id(max_id, dateconv=True) 1786 max_id = self.__unpack_id(max_id, dateconv=True)
1787 1787
1788 if min_id != None: 1788 if min_id is not None:
1789 min_id = self.__unpack_id(min_id, dateconv=True) 1789 min_id = self.__unpack_id(min_id, dateconv=True)
1790 1790
1791 if since_id != None: 1791 if since_id is not None:
1792 since_id = self.__unpack_id(since_id, dateconv=True) 1792 since_id = self.__unpack_id(since_id, dateconv=True)
1793 1793
1794 params = self.__generate_params(locals()) 1794 params = self.__generate_params(locals())
@@ -1857,13 +1857,13 @@ class Mastodon:
1857 1857
1858 Returns a `toot dict`_ with the new status. 1858 Returns a `toot dict`_ with the new status.
1859 """ 1859 """
1860 if quote_id != None: 1860 if quote_id is not None:
1861 if self.feature_set != "fedibird": 1861 if self.feature_set != "fedibird":
1862 raise MastodonIllegalArgumentError( 1862 raise MastodonIllegalArgumentError(
1863 'quote_id is only available with feature set fedibird') 1863 'quote_id is only available with feature set fedibird')
1864 quote_id = self.__unpack_id(quote_id) 1864 quote_id = self.__unpack_id(quote_id)
1865 1865
1866 if content_type != None: 1866 if content_type is not None:
1867 if self.feature_set != "pleroma": 1867 if self.feature_set != "pleroma":
1868 raise MastodonIllegalArgumentError( 1868 raise MastodonIllegalArgumentError(
1869 'content_type is only available with feature set pleroma') 1869 'content_type is only available with feature set pleroma')
@@ -1872,23 +1872,23 @@ class Mastodon:
1872 raise MastodonIllegalArgumentError( 1872 raise MastodonIllegalArgumentError(
1873 'Invalid content type specified') 1873 'Invalid content type specified')
1874 1874
1875 if in_reply_to_id != None: 1875 if in_reply_to_id is not None:
1876 in_reply_to_id = self.__unpack_id(in_reply_to_id) 1876 in_reply_to_id = self.__unpack_id(in_reply_to_id)
1877 1877
1878 if scheduled_at != None: 1878 if scheduled_at is not None:
1879 scheduled_at = self.__consistent_isoformat_utc(scheduled_at) 1879 scheduled_at = self.__consistent_isoformat_utc(scheduled_at)
1880 1880
1881 params_initial = locals() 1881 params_initial = locals()
1882 1882
1883 # Validate poll/media exclusivity 1883 # Validate poll/media exclusivity
1884 if not poll is None: 1884 if poll is not None:
1885 if (not media_ids is None) and len(media_ids) != 0: 1885 if media_ids is not None and len(media_ids) != 0:
1886 raise ValueError( 1886 raise ValueError(
1887 'Status can have media or poll attached - not both.') 1887 'Status can have media or poll attached - not both.')
1888 1888
1889 # Validate visibility parameter 1889 # Validate visibility parameter
1890 valid_visibilities = ['private', 'public', 'unlisted', 'direct'] 1890 valid_visibilities = ['private', 'public', 'unlisted', 'direct']
1891 if params_initial['visibility'] == None: 1891 if params_initial['visibility'] is None:
1892 del params_initial['visibility'] 1892 del params_initial['visibility']
1893 else: 1893 else:
1894 params_initial['visibility'] = params_initial['visibility'].lower() 1894 params_initial['visibility'] = params_initial['visibility'].lower()
@@ -1896,14 +1896,14 @@ class Mastodon:
1896 raise ValueError('Invalid visibility value! Acceptable ' 1896 raise ValueError('Invalid visibility value! Acceptable '
1897 'values are %s' % valid_visibilities) 1897 'values are %s' % valid_visibilities)
1898 1898
1899 if params_initial['language'] == None: 1899 if params_initial['language'] is None:
1900 del params_initial['language'] 1900 del params_initial['language']
1901 1901
1902 if params_initial['sensitive'] is False: 1902 if params_initial['sensitive'] is False:
1903 del [params_initial['sensitive']] 1903 del [params_initial['sensitive']]
1904 1904
1905 headers = {} 1905 headers = {}
1906 if idempotency_key != None: 1906 if idempotency_key is not None:
1907 headers['Idempotency-Key'] = idempotency_key 1907 headers['Idempotency-Key'] = idempotency_key
1908 1908
1909 if media_ids is not None: 1909 if media_ids is not None:
@@ -1919,11 +1919,11 @@ class Mastodon:
1919 1919
1920 params_initial["media_ids"] = media_ids_proper 1920 params_initial["media_ids"] = media_ids_proper
1921 1921
1922 if params_initial['content_type'] == None: 1922 if params_initial['content_type'] is None:
1923 del params_initial['content_type'] 1923 del params_initial['content_type']
1924 1924
1925 use_json = False 1925 use_json = False
1926 if not poll is None: 1926 if poll is not None:
1927 use_json = True 1927 use_json = True
1928 1928
1929 params = self.__generate_params(params_initial, ['idempotency_key']) 1929 params = self.__generate_params(params_initial, ['idempotency_key'])
@@ -1975,9 +1975,9 @@ class Mastodon:
1975 mentioned_accounts.values())) + status 1975 mentioned_accounts.values())) + status
1976 1976
1977 # Retain visibility / cw 1977 # Retain visibility / cw
1978 if visibility == None and 'visibility' in to_status: 1978 if visibility is None and 'visibility' in to_status:
1979 visibility = to_status.visibility 1979 visibility = to_status.visibility
1980 if spoiler_text == None and 'spoiler_text' in to_status: 1980 if spoiler_text is None and 'spoiler_text' in to_status:
1981 spoiler_text = to_status.spoiler_text 1981 spoiler_text = to_status.spoiler_text
1982 1982
1983 keyword_args["status"] = status 1983 keyword_args["status"] = status
@@ -2243,7 +2243,7 @@ class Mastodon:
2243 id = self.__unpack_id(id) 2243 id = self.__unpack_id(id)
2244 params = self.__generate_params(locals()) 2244 params = self.__generate_params(locals())
2245 2245
2246 if params["reblogs"] == None: 2246 if params["reblogs"] is None:
2247 del params["reblogs"] 2247 del params["reblogs"]
2248 2248
2249 url = '/api/v1/accounts/{0}/follow'.format(str(id)) 2249 url = '/api/v1/accounts/{0}/follow'.format(str(id))
@@ -2347,7 +2347,7 @@ class Mastodon:
2347 params_initial = collections.OrderedDict(locals()) 2347 params_initial = collections.OrderedDict(locals())
2348 2348
2349 # Convert fields 2349 # Convert fields
2350 if fields != None: 2350 if fields is not None:
2351 if len(fields) > 4: 2351 if len(fields) > 4:
2352 raise MastodonIllegalArgumentError( 2352 raise MastodonIllegalArgumentError(
2353 'A maximum of four fields are allowed.') 2353 'A maximum of four fields are allowed.')
@@ -2366,9 +2366,9 @@ class Mastodon:
2366 2366
2367 # Create file info 2367 # Create file info
2368 files = {} 2368 files = {}
2369 if not avatar is None: 2369 if avatar is not None:
2370 files["avatar"] = self.__load_media_file(avatar, avatar_mime_type) 2370 files["avatar"] = self.__load_media_file(avatar, avatar_mime_type)
2371 if not header is None: 2371 if header is not None:
2372 files["header"] = self.__load_media_file(header, header_mime_type) 2372 files["header"] = self.__load_media_file(header, header_mime_type)
2373 2373
2374 params = self.__generate_params(params_initial) 2374 params = self.__generate_params(params_initial)
@@ -2581,13 +2581,13 @@ class Mastodon:
2581 """ 2581 """
2582 account_id = self.__unpack_id(account_id) 2582 account_id = self.__unpack_id(account_id)
2583 2583
2584 if not status_ids is None: 2584 if status_ids is not None:
2585 if not isinstance(status_ids, list): 2585 if not isinstance(status_ids, list):
2586 status_ids = [status_ids] 2586 status_ids = [status_ids]
2587 status_ids = list(map(lambda x: self.__unpack_id(x), status_ids)) 2587 status_ids = list(map(lambda x: self.__unpack_id(x), status_ids))
2588 2588
2589 params_initial = locals() 2589 params_initial = locals()
2590 if forward == False: 2590 if not forward:
2591 del params_initial['forward'] 2591 del params_initial['forward']
2592 2592
2593 params = self.__generate_params(params_initial) 2593 params = self.__generate_params(params_initial)
@@ -2653,10 +2653,10 @@ class Mastodon:
2653 files = {'file': self.__load_media_file( 2653 files = {'file': self.__load_media_file(
2654 media_file, mime_type, file_name)} 2654 media_file, mime_type, file_name)}
2655 2655
2656 if focus != None: 2656 if focus is not None:
2657 focus = str(focus[0]) + "," + str(focus[1]) 2657 focus = str(focus[0]) + "," + str(focus[1])
2658 2658
2659 if not thumbnail is None: 2659 if thumbnail is not None:
2660 if not self.verify_minimum_version("3.2.0", cached=True): 2660 if not self.verify_minimum_version("3.2.0", cached=True):
2661 raise MastodonVersionError( 2661 raise MastodonVersionError(
2662 'Thumbnail requires version > 3.2.0') 2662 'Thumbnail requires version > 3.2.0')
@@ -2674,7 +2674,7 @@ class Mastodon:
2674 # Wait for processing? 2674 # Wait for processing?
2675 if synchronous: 2675 if synchronous:
2676 if self.verify_minimum_version("3.1.4"): 2676 if self.verify_minimum_version("3.1.4"):
2677 while not "url" in ret_dict or ret_dict.url == None: 2677 while not "url" in ret_dict or ret_dict.url is None:
2678 try: 2678 try:
2679 ret_dict = self.media(ret_dict) 2679 ret_dict = self.media(ret_dict)
2680 time.sleep(1.0) 2680 time.sleep(1.0)
@@ -2697,13 +2697,13 @@ class Mastodon:
2697 """ 2697 """
2698 id = self.__unpack_id(id) 2698 id = self.__unpack_id(id)
2699 2699
2700 if focus != None: 2700 if focus is not None:
2701 focus = str(focus[0]) + "," + str(focus[1]) 2701 focus = str(focus[0]) + "," + str(focus[1])
2702 2702
2703 params = self.__generate_params( 2703 params = self.__generate_params(
2704 locals(), ['id', 'thumbnail', 'thumbnail_mime_type']) 2704 locals(), ['id', 'thumbnail', 'thumbnail_mime_type'])
2705 2705
2706 if not thumbnail is None: 2706 if thumbnail is not None:
2707 if not self.verify_minimum_version("3.2.0", cached=True): 2707 if not self.verify_minimum_version("3.2.0", cached=True):
2708 raise MastodonVersionError( 2708 raise MastodonVersionError(
2709 'Thumbnail requires version > 3.2.0') 2709 'Thumbnail requires version > 3.2.0')
@@ -2809,25 +2809,25 @@ class Mastodon:
2809 'policy': policy 2809 'policy': policy
2810 } 2810 }
2811 2811
2812 if follow_events != None: 2812 if follow_events is not None:
2813 params['data[alerts][follow]'] = follow_events 2813 params['data[alerts][follow]'] = follow_events
2814 2814
2815 if favourite_events != None: 2815 if favourite_events is not None:
2816 params['data[alerts][favourite]'] = favourite_events 2816 params['data[alerts][favourite]'] = favourite_events
2817 2817
2818 if reblog_events != None: 2818 if reblog_events is not None:
2819 params['data[alerts][reblog]'] = reblog_events 2819 params['data[alerts][reblog]'] = reblog_events
2820 2820
2821 if mention_events != None: 2821 if mention_events is not None:
2822 params['data[alerts][mention]'] = mention_events 2822 params['data[alerts][mention]'] = mention_events
2823 2823
2824 if poll_events != None: 2824 if poll_events is not None:
2825 params['data[alerts][poll]'] = poll_events 2825 params['data[alerts][poll]'] = poll_events
2826 2826
2827 if follow_request_events != None: 2827 if follow_request_events is not None:
2828 params['data[alerts][follow_request]'] = follow_request_events 2828 params['data[alerts][follow_request]'] = follow_request_events
2829 2829
2830 if follow_request_events != None: 2830 if follow_request_events is not None:
2831 params['data[alerts][status]'] = status_events 2831 params['data[alerts][status]'] = status_events
2832 2832
2833 # Canonicalize booleans 2833 # Canonicalize booleans
@@ -2847,22 +2847,22 @@ class Mastodon:
2847 """ 2847 """
2848 params = {} 2848 params = {}
2849 2849
2850 if follow_events != None: 2850 if follow_events is not None:
2851 params['data[alerts][follow]'] = follow_events 2851 params['data[alerts][follow]'] = follow_events
2852 2852
2853 if favourite_events != None: 2853 if favourite_events is not None:
2854 params['data[alerts][favourite]'] = favourite_events 2854 params['data[alerts][favourite]'] = favourite_events
2855 2855
2856 if reblog_events != None: 2856 if reblog_events is not None:
2857 params['data[alerts][reblog]'] = reblog_events 2857 params['data[alerts][reblog]'] = reblog_events
2858 2858
2859 if mention_events != None: 2859 if mention_events is not None:
2860 params['data[alerts][mention]'] = mention_events 2860 params['data[alerts][mention]'] = mention_events
2861 2861
2862 if poll_events != None: 2862 if poll_events is not None:
2863 params['data[alerts][poll]'] = poll_events 2863 params['data[alerts][poll]'] = poll_events
2864 2864
2865 if follow_request_events != None: 2865 if follow_request_events is not None:
2866 params['data[alerts][follow_request]'] = follow_request_events 2866 params['data[alerts][follow_request]'] = follow_request_events
2867 2867
2868 # Canonicalize booleans 2868 # Canonicalize booleans
@@ -2941,19 +2941,19 @@ class Mastodon:
2941 2941
2942 Returns a list of `admin account dicts`_. 2942 Returns a list of `admin account dicts`_.
2943 """ 2943 """
2944 if max_id != None: 2944 if max_id is not None:
2945 max_id = self.__unpack_id(max_id, dateconv=True) 2945 max_id = self.__unpack_id(max_id, dateconv=True)
2946 2946
2947 if min_id != None: 2947 if min_id is not None:
2948 min_id = self.__unpack_id(min_id, dateconv=True) 2948 min_id = self.__unpack_id(min_id, dateconv=True)
2949 2949
2950 if since_id != None: 2950 if since_id is not None:
2951 since_id = self.__unpack_id(since_id, dateconv=True) 2951 since_id = self.__unpack_id(since_id, dateconv=True)
2952 2952
2953 params = self.__generate_params( 2953 params = self.__generate_params(
2954 locals(), ['remote', 'status', 'staff_only']) 2954 locals(), ['remote', 'status', 'staff_only'])
2955 2955
2956 if remote == True: 2956 if remote:
2957 params["remote"] = True 2957 params["remote"] = True
2958 2958
2959 mod_statuses = ["active", "pending", 2959 mod_statuses = ["active", "pending",
@@ -2961,7 +2961,7 @@ class Mastodon:
2961 if not status in mod_statuses: 2961 if not status in mod_statuses:
2962 raise ValueError("Invalid moderation status requested.") 2962 raise ValueError("Invalid moderation status requested.")
2963 2963
2964 if staff_only == True: 2964 if staff_only:
2965 params["staff"] = True 2965 params["staff"] = True
2966 2966
2967 for mod_status in mod_statuses: 2967 for mod_status in mod_statuses:
@@ -3073,11 +3073,11 @@ class Mastodon:
3073 if action is None: 3073 if action is None:
3074 action = "none" 3074 action = "none"
3075 3075
3076 if send_email_notification == False: 3076 if not send_email_notification:
3077 send_email_notification = None 3077 send_email_notification = None
3078 3078
3079 id = self.__unpack_id(id) 3079 id = self.__unpack_id(id)
3080 if not report_id is None: 3080 if report_id is not None:
3081 report_id = self.__unpack_id(report_id) 3081 report_id = self.__unpack_id(report_id)
3082 3082
3083 params = self.__generate_params(locals(), ['id', 'action']) 3083 params = self.__generate_params(locals(), ['id', 'action'])
@@ -3097,22 +3097,22 @@ class Mastodon:
3097 3097
3098 Returns a list of `report dicts`_. 3098 Returns a list of `report dicts`_.
3099 """ 3099 """
3100 if max_id != None: 3100 if max_id is not None:
3101 max_id = self.__unpack_id(max_id, dateconv=True) 3101 max_id = self.__unpack_id(max_id, dateconv=True)
3102 3102
3103 if min_id != None: 3103 if min_id is not None:
3104 min_id = self.__unpack_id(min_id, dateconv=True) 3104 min_id = self.__unpack_id(min_id, dateconv=True)
3105 3105
3106 if since_id != None: 3106 if since_id is not None:
3107 since_id = self.__unpack_id(since_id, dateconv=True) 3107 since_id = self.__unpack_id(since_id, dateconv=True)
3108 3108
3109 if not account_id is None: 3109 if account_id is not None:
3110 account_id = self.__unpack_id(account_id) 3110 account_id = self.__unpack_id(account_id)
3111 3111
3112 if not target_account_id is None: 3112 if target_account_id is not None:
3113 target_account_id = self.__unpack_id(target_account_id) 3113 target_account_id = self.__unpack_id(target_account_id)
3114 3114
3115 if resolved == False: 3115 if not resolved:
3116 resolved = None 3116 resolved = None
3117 3117
3118 params = self.__generate_params(locals()) 3118 params = self.__generate_params(locals())
@@ -3269,12 +3269,12 @@ class Mastodon:
3269 # Figure out what size to decode to 3269 # Figure out what size to decode to
3270 decode_components_x, decode_components_y = blurhash.components( 3270 decode_components_x, decode_components_y = blurhash.components(
3271 media_dict["blurhash"]) 3271 media_dict["blurhash"])
3272 if size_per_component == False: 3272 if size_per_component:
3273 decode_size_x = out_size[0]
3274 decode_size_y = out_size[1]
3275 else:
3276 decode_size_x = decode_components_x * out_size[0] 3273 decode_size_x = decode_components_x * out_size[0]
3277 decode_size_y = decode_components_y * out_size[1] 3274 decode_size_y = decode_components_y * out_size[1]
3275 else:
3276 decode_size_x = out_size[0]
3277 decode_size_y = out_size[1]
3278 3278
3279 # Decode 3279 # Decode
3280 decoded_image = blurhash.decode( 3280 decoded_image = blurhash.decode(
@@ -3444,7 +3444,7 @@ class Mastodon:
3444 """ 3444 """
3445 Fetch the logged in user's ID, with caching. ID is reset on calls to log_in. 3445 Fetch the logged in user's ID, with caching. ID is reset on calls to log_in.
3446 """ 3446 """
3447 if self.__logged_in_id == None: 3447 if self.__logged_in_id is None:
3448 self.__logged_in_id = self.account_verify_credentials().id 3448 self.__logged_in_id = self.account_verify_credentials().id
3449 return self.__logged_in_id 3449 return self.__logged_in_id
3450 3450
@@ -3467,7 +3467,7 @@ class Mastodon:
3467 "updated_at", "last_status_at", "starts_at", "ends_at", "published_at", "edited_at"] 3467 "updated_at", "last_status_at", "starts_at", "ends_at", "published_at", "edited_at"]
3468 for k, v in json_object.items(): 3468 for k, v in json_object.items():
3469 if k in known_date_fields: 3469 if k in known_date_fields:
3470 if v != None: 3470 if v is not None:
3471 try: 3471 try:
3472 if isinstance(v, int): 3472 if isinstance(v, int):
3473 json_object[k] = datetime.datetime.fromtimestamp(v, pytz.utc) 3473 json_object[k] = datetime.datetime.fromtimestamp(v, pytz.utc)
@@ -3555,9 +3555,9 @@ class Mastodon:
3555 3555
3556 # Generate request headers 3556 # Generate request headers
3557 headers = copy.deepcopy(headers) 3557 headers = copy.deepcopy(headers)
3558 if not self.access_token is None: 3558 if self.access_token is not None:
3559 headers['Authorization'] = 'Bearer ' + self.access_token 3559 headers['Authorization'] = 'Bearer ' + self.access_token
3560 if not access_token_override is None: 3560 if access_token_override is not None:
3561 headers['Authorization'] = 'Bearer ' + access_token_override 3561 headers['Authorization'] = 'Bearer ' + access_token_override
3562 3562
3563 # Add user-agent 3563 # Add user-agent
@@ -3566,7 +3566,7 @@ class Mastodon:
3566 3566
3567 # Determine base URL 3567 # Determine base URL
3568 base_url = self.api_base_url 3568 base_url = self.api_base_url
3569 if not base_url_override is None: 3569 if base_url_override is not None:
3570 base_url = base_url_override 3570 base_url = base_url_override
3571 3571
3572 if self.debug_requests: 3572 if self.debug_requests:
@@ -3584,13 +3584,12 @@ class Mastodon:
3584 response_object = None 3584 response_object = None
3585 try: 3585 try:
3586 kwargs = dict(headers=headers, files=files, timeout=self.request_timeout) 3586 kwargs = dict(headers=headers, files=files, timeout=self.request_timeout)
3587 if use_json == False: 3587 if use_json:
3588 if method == 'GET':
3589 kwargs['params'] = params
3590 else:
3591 kwargs['data'] = params
3592 else:
3593 kwargs['json'] = params 3588 kwargs['json'] = params
3589 elif method == 'GET':
3590 kwargs['params'] = params
3591 else:
3592 kwargs['data'] = params
3594 3593
3595 # Block list with exactly three entries, matching on hashes of the instance API domain 3594 # Block list with exactly three entries, matching on hashes of the instance API domain
3596 # For more information, have a look at the docs 3595 # For more information, have a look at the docs
@@ -3626,7 +3625,7 @@ class Mastodon:
3626 ratelimit_intrep = None 3625 ratelimit_intrep = None
3627 3626
3628 try: 3627 try:
3629 if not ratelimit_intrep is None and ratelimit_intrep == response_object.headers['X-RateLimit-Reset']: 3628 if ratelimit_intrep is not None and ratelimit_intrep == response_object.headers['X-RateLimit-Reset']:
3630 self.ratelimit_reset = int( 3629 self.ratelimit_reset = int(
3631 response_object.headers['X-RateLimit-Reset']) 3630 response_object.headers['X-RateLimit-Reset'])
3632 else: 3631 else:
@@ -3679,7 +3678,7 @@ class Mastodon:
3679 request_complete = False 3678 request_complete = False
3680 continue 3679 continue
3681 3680
3682 if skip_error_check == False: 3681 if not skip_error_check:
3683 if response_object.status_code == 404: 3682 if response_object.status_code == 404:
3684 ex_type = MastodonNotFoundError 3683 ex_type = MastodonNotFoundError
3685 if not error_msg: 3684 if not error_msg:
@@ -3708,7 +3707,7 @@ class Mastodon:
3708 if return_response_object: 3707 if return_response_object:
3709 return response_object 3708 return response_object
3710 3709
3711 if parse == True: 3710 if parse:
3712 try: 3711 try:
3713 response = response_object.json( 3712 response = response_object.json(
3714 object_hook=self.__json_hooks) 3713 object_hook=self.__json_hooks)
@@ -3871,7 +3870,7 @@ class Mastodon:
3871 3870
3872 def close(self): 3871 def close(self):
3873 self.closed = True 3872 self.closed = True
3874 if not self.connection is None: 3873 if self.connection is not None:
3875 self.connection.close() 3874 self.connection.close()
3876 3875
3877 def is_alive(self): 3876 def is_alive(self):
@@ -3897,7 +3896,7 @@ class Mastodon:
3897 3896
3898 # Run until closed or until error if not autoreconnecting 3897 # Run until closed or until error if not autoreconnecting
3899 while self.running: 3898 while self.running:
3900 if not self.connection is None: 3899 if self.connection is not None:
3901 with closing(self.connection) as r: 3900 with closing(self.connection) as r:
3902 try: 3901 try:
3903 listener.handle_stream(r) 3902 listener.handle_stream(r)
@@ -3968,10 +3967,8 @@ class Mastodon:
3968 3967
3969 param_keys = list(params.keys()) 3968 param_keys = list(params.keys())
3970 for key in param_keys: 3969 for key in param_keys:
3971 if isinstance(params[key], bool) and params[key] == False: 3970 if isinstance(params[key], bool):
3972 params[key] = '0' 3971 params[key] = '1' if params[key] else '0'
3973 if isinstance(params[key], bool) and params[key] == True:
3974 params[key] = '1'
3975 3972
3976 for key in param_keys: 3973 for key in param_keys:
3977 if params[key] is None or key in exclude: 3974 if params[key] is None or key in exclude:
diff --git a/mastodon/streaming.py b/mastodon/streaming.py
index e43d7d6..08f5670 100644
--- a/mastodon/streaming.py
+++ b/mastodon/streaming.py
@@ -213,11 +213,11 @@ class CallbackStreamListener(StreamListener):
213 self.status_update_handler = status_update_handler 213 self.status_update_handler = status_update_handler
214 214
215 def on_update(self, status): 215 def on_update(self, status):
216 if self.update_handler != None: 216 if self.update_handler is not None:
217 self.update_handler(status) 217 self.update_handler(status)
218 218
219 try: 219 try:
220 if self.local_update_handler != None and not "@" in status["account"]["acct"]: 220 if self.local_update_handler is not None and not "@" in status["account"]["acct"]:
221 self.local_update_handler(status) 221 self.local_update_handler(status)
222 except Exception as err: 222 except Exception as err:
223 six.raise_from( 223 six.raise_from(
@@ -226,21 +226,21 @@ class CallbackStreamListener(StreamListener):
226 ) 226 )
227 227
228 def on_delete(self, deleted_id): 228 def on_delete(self, deleted_id):
229 if self.delete_handler != None: 229 if self.delete_handler is not None:
230 self.delete_handler(deleted_id) 230 self.delete_handler(deleted_id)
231 231
232 def on_notification(self, notification): 232 def on_notification(self, notification):
233 if self.notification_handler != None: 233 if self.notification_handler is not None:
234 self.notification_handler(notification) 234 self.notification_handler(notification)
235 235
236 def on_conversation(self, conversation): 236 def on_conversation(self, conversation):
237 if self.conversation_handler != None: 237 if self.conversation_handler is not None:
238 self.conversation_handler(conversation) 238 self.conversation_handler(conversation)
239 239
240 def on_unknown_event(self, name, unknown_event=None): 240 def on_unknown_event(self, name, unknown_event=None):
241 if self.unknown_event_handler != None: 241 if self.unknown_event_handler is not None:
242 self.unknown_event_handler(name, unknown_event) 242 self.unknown_event_handler(name, unknown_event)
243 243
244 def on_status_update(self, status): 244 def on_status_update(self, status):
245 if self.status_update_handler != None: 245 if self.status_update_handler is not None:
246 self.status_update_handler(status) 246 self.status_update_handler(status)
diff --git a/tests/test_account.py b/tests/test_account.py
index 6f3b9a5..be48646 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -252,7 +252,7 @@ def test_featured_tags(api):
252 assert featured_tag_list[0].name == "coolfree" 252 assert featured_tag_list[0].name == "coolfree"
253 assert "url" in featured_tag_list[0] 253 assert "url" in featured_tag_list[0]
254 finally: 254 finally:
255 if not featured_tag is None: 255 if featured_tag is not None:
256 api.featured_tag_delete(featured_tag) 256 api.featured_tag_delete(featured_tag)
257 api.featured_tag_delete(featured_tag_2) 257 api.featured_tag_delete(featured_tag_2)
258 258
diff --git a/tests/test_bookmarks.py b/tests/test_bookmarks.py
index e5e0d7c..54134e9 100644
--- a/tests/test_bookmarks.py
+++ b/tests/test_bookmarks.py
@@ -4,7 +4,7 @@ import pytest
4def test_bookmarks(api, status): 4def test_bookmarks(api, status):
5 status_bookmarked = api.status_bookmark(status) 5 status_bookmarked = api.status_bookmark(status)
6 assert status_bookmarked 6 assert status_bookmarked
7 assert status_bookmarked.bookmarked == True 7 assert status_bookmarked.bookmarked
8 8
9 bookmarked_statuses = api.bookmarks() 9 bookmarked_statuses = api.bookmarks()
10 assert bookmarked_statuses 10 assert bookmarked_statuses
@@ -18,9 +18,9 @@ def test_bookmarks(api, status):
18 18
19 status_unbookmarked = api.status_unbookmark(status_bookmarked) 19 status_unbookmarked = api.status_unbookmark(status_bookmarked)
20 assert status_unbookmarked 20 assert status_unbookmarked
21 assert status_unbookmarked.bookmarked == False 21 assert not status_unbookmarked.bookmarked
22 22
23 bookmarked_statuses_2 = api.bookmarks() 23 bookmarked_statuses_2 = api.bookmarks()
24 assert not bookmarked_statuses_2 is None 24 assert bookmarked_statuses_2 is not None
25 assert len(bookmarked_statuses_2) == len(bookmarked_statuses) - 1 25 assert len(bookmarked_statuses_2) == len(bookmarked_statuses) - 1
26 26
diff --git a/tests/test_constructor.py b/tests/test_constructor.py
index ebc9b85..d997a5d 100644
--- a/tests/test_constructor.py
+++ b/tests/test_constructor.py
@@ -33,9 +33,9 @@ def test_constructor_missing_client_secret():
33 33
34@pytest.mark.vcr() 34@pytest.mark.vcr()
35def test_verify_version(api): 35def test_verify_version(api):
36 assert api.verify_minimum_version("2.3.3") == True 36 assert api.verify_minimum_version("2.3.3") is True
37 assert api.verify_minimum_version("9999.9999.9999") == False 37 assert api.verify_minimum_version("9999.9999.9999") is False
38 assert api.verify_minimum_version("1.0.0") == True 38 assert api.verify_minimum_version("1.0.0") is True
39 39
40def test_supported_version(api): 40def test_supported_version(api):
41 assert Mastodon.get_supported_version() \ No newline at end of file 41 assert Mastodon.get_supported_version() \ No newline at end of file
diff --git a/tests/test_filters.py b/tests/test_filters.py
index 3ffa726..d3dab8d 100644
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -7,12 +7,12 @@ def test_filter_create(api):
7 with vcr.use_cassette('test_filter_create.yaml', cassette_library_dir='tests/cassettes_pre_4_0_0', record_mode='none'): 7 with vcr.use_cassette('test_filter_create.yaml', cassette_library_dir='tests/cassettes_pre_4_0_0', record_mode='none'):
8 keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = True, expires_in = None) 8 keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = True, expires_in = None)
9 try: 9 try:
10 assert(keyword_filter) 10 assert keyword_filter
11 11
12 all_filters = api.filters() 12 all_filters = api.filters()
13 assert(keyword_filter in all_filters) 13 assert keyword_filter in all_filters
14 assert(keyword_filter.irreversible == False) 14 assert keyword_filter.irreversible is False
15 assert(keyword_filter.whole_word == True) 15 assert keyword_filter.whole_word is True
16 16
17 keyword_filter_2 = api.filter(keyword_filter.id) 17 keyword_filter_2 = api.filter(keyword_filter.id)
18 assert(keyword_filter == keyword_filter_2) 18 assert(keyword_filter == keyword_filter_2)
@@ -22,9 +22,9 @@ def test_filter_create(api):
22 22
23 keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = False, expires_in = None) 23 keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = False, expires_in = None)
24 try: 24 try:
25 assert(keyword_filter) 25 assert keyword_filter
26 assert(keyword_filter.irreversible == False) 26 assert keyword_filter.irreversible is False
27 assert(keyword_filter.whole_word == False) 27 assert keyword_filter.whole_word is False
28 28
29 all_filters = api.filters() 29 all_filters = api.filters()
30 assert(keyword_filter in all_filters) 30 assert(keyword_filter in all_filters)
diff --git a/tests/test_hooks.py b/tests/test_hooks.py
index f0139e5..ab33d4c 100644
--- a/tests/test_hooks.py
+++ b/tests/test_hooks.py
@@ -32,7 +32,7 @@ def test_date_hook(status):
32 32
33@pytest.mark.vcr() 33@pytest.mark.vcr()
34def test_attribute_access(status): 34def test_attribute_access(status):
35 assert status.id != None 35 assert status.id is not None
36 with pytest.raises(AttributeError): 36 with pytest.raises(AttributeError):
37 status.id = 420 37 status.id = 420
38 \ No newline at end of file 38 \ No newline at end of file
diff --git a/tests/test_instance.py b/tests/test_instance.py
index 8f3f142..1fbd692 100644
--- a/tests/test_instance.py
+++ b/tests/test_instance.py
@@ -38,7 +38,7 @@ def test_emoji(api):
38 38
39@pytest.mark.vcr() 39@pytest.mark.vcr()
40def test_health(api): 40def test_health(api):
41 assert api.instance_health() == True 41 assert api.instance_health() is True
42 42
43@pytest.mark.vcr() 43@pytest.mark.vcr()
44def test_server_time(api): 44def test_server_time(api):
diff --git a/tests/test_media.py b/tests/test_media.py
index 7a358dd..e16fb4d 100644
--- a/tests/test_media.py
+++ b/tests/test_media.py
@@ -21,7 +21,7 @@ def test_media_post_v1(api):
21 assert status 21 assert status
22 22
23 try: 23 try:
24 assert status['sensitive'] == False 24 assert status['sensitive'] is False
25 assert status['media_attachments'] 25 assert status['media_attachments']
26 assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk" 26 assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk"
27 assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5 27 assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5
@@ -45,7 +45,7 @@ def test_media_post(api, sensitive):
45 time.sleep(10) 45 time.sleep(10)
46 media2 = api.media(media) 46 media2 = api.media(media)
47 assert media2.id == media.id 47 assert media2.id == media.id
48 assert not media2.url is None 48 assert media2.url is not None
49 49
50 status = api.status_post( 50 status = api.status_post(
51 'LOL check this out', 51 'LOL check this out',
diff --git a/tests/test_notifications.py b/tests/test_notifications.py
index 6e761ce..858bad4 100644
--- a/tests/test_notifications.py
+++ b/tests/test_notifications.py
@@ -29,7 +29,7 @@ def test_notifications_dismiss_pre_2_9_2(api, api2):
29 api.verify_minimum_version("2.9.2", cached=False) 29 api.verify_minimum_version("2.9.2", cached=False)
30 api.notifications_dismiss(notifications[0]) 30 api.notifications_dismiss(notifications[0])
31 finally: 31 finally:
32 if not status is None: 32 if status is not None:
33 api2.status_delete(status) 33 api2.status_delete(status)
34 34
35@pytest.mark.vcr() 35@pytest.mark.vcr()
diff --git a/tests/test_push.py b/tests/test_push.py
index daa99c7..b815910 100644
--- a/tests/test_push.py
+++ b/tests/test_push.py
@@ -57,14 +57,14 @@ def test_push_update(api):
57 print(sub3) 57 print(sub3)
58 print(api.push_subscription()) 58 print(api.push_subscription())
59 59
60 assert sub3.alerts.follow == False 60 assert sub3.alerts.follow is False
61 assert sub3.alerts.favourite == False 61 assert sub3.alerts.favourite is False
62 assert sub3.alerts.reblog == False 62 assert sub3.alerts.reblog is False
63 assert sub3.alerts.mention == False 63 assert sub3.alerts.mention is False
64 assert sub2.alerts.follow == True 64 assert sub2.alerts.follow is True
65 assert sub2.alerts.favourite == True 65 assert sub2.alerts.favourite is True
66 assert sub2.alerts.reblog == True 66 assert sub2.alerts.reblog is True
67 assert sub2.alerts.mention == True 67 assert sub2.alerts.mention is True
68 68
69 69
70@pytest.mark.vcr(match_on=['path']) 70@pytest.mark.vcr(match_on=['path'])
diff --git a/tests/test_streaming.py b/tests/test_streaming.py
index fb60fe1..53a71ee 100644
--- a/tests/test_streaming.py
+++ b/tests/test_streaming.py
@@ -20,7 +20,7 @@ close_connections = False
20def patch_streaming(): 20def patch_streaming():
21 global streaming_is_patched 21 global streaming_is_patched
22 global close_connections 22 global close_connections
23 if streaming_is_patched == True: 23 if streaming_is_patched is True:
24 return 24 return
25 streaming_is_patched = True 25 streaming_is_patched = True
26 26
@@ -35,7 +35,7 @@ def patch_streaming():
35 response = real_connection_real_get_response(*args, **kwargs) 35 response = real_connection_real_get_response(*args, **kwargs)
36 real_body = b"" 36 real_body = b""
37 try: 37 try:
38 while close_connections == False: 38 while close_connections is False:
39 if len(select.select([response], [], [], 0.01)[0]) > 0: 39 if len(select.select([response], [], [], 0.01)[0]) > 0:
40 chunk = response.read(1) 40 chunk = response.read(1)
41 real_body += chunk 41 real_body += chunk
@@ -165,7 +165,7 @@ def test_unknown_event():
165 'data: {}', 165 'data: {}',
166 '', 166 '',
167 ]) 167 ])
168 assert listener.bla_called == True 168 assert listener.bla_called is True
169 assert listener.updates == [] 169 assert listener.updates == []
170 assert listener.notifications == [] 170 assert listener.notifications == []
171 assert listener.deletes == [] 171 assert listener.deletes == []
@@ -195,7 +195,7 @@ def test_dotted_unknown_event():
195 'data: {}', 195 'data: {}',
196 '', 196 '',
197 ]) 197 ])
198 assert listener.do_something_called == True 198 assert listener.do_something_called is True
199 assert listener.updates == [] 199 assert listener.updates == []
200 assert listener.notifications == [] 200 assert listener.notifications == []
201 assert listener.deletes == [] 201 assert listener.deletes == []
diff --git a/tests/test_timeline.py b/tests/test_timeline.py
index bc6728f..239fac3 100644
--- a/tests/test_timeline.py
+++ b/tests/test_timeline.py
@@ -60,8 +60,8 @@ def test_conversations(api, api2):
60 assert conversations 60 assert conversations
61 assert status.id in map(lambda x: x.last_status.id, conversations) 61 assert status.id in map(lambda x: x.last_status.id, conversations)
62 assert account.id in map(lambda x: x.accounts[0].id, conversations) 62 assert account.id in map(lambda x: x.accounts[0].id, conversations)
63 assert conversations[0].unread == True 63 assert conversations[0].unread is True
64 assert conversations2[0].unread == False 64 assert conversations2[0].unread is False
65 65
66@pytest.mark.vcr() 66@pytest.mark.vcr()
67def test_min_max_id(api, status): 67def test_min_max_id(api, status):
Powered by cgit v1.2.3 (git 2.41.0)