diff --git a/files/classes/badges.py b/files/classes/badges.py index 841661616..cce94627d 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -74,7 +74,7 @@ class Badge(Base): def text(self): if self.until: text = self.badge.description + " until" - elif self.badge_id in (28, 170, 179): + elif self.badge_id in {28, 170, 179}: text = self.badge.description + " permanently" elif self.description: text = self.description diff --git a/files/classes/comment.py b/files/classes/comment.py index e727c1810..f176955cb 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -284,7 +284,7 @@ class Comment(Base): if v: sub = self.post.sub - if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): body += ' disabled ' + if sub in {'furry','vampire','racist','femboy'} and not v.house.lower().startswith(sub): body += ' disabled ' body += f''' onchange="poll_vote_{o.exclusive}('{o.id}', '{self.id}', 'comment')"''' else: body += f''' onchange="poll_vote_no_v()"''' diff --git a/files/classes/submission.py b/files/classes/submission.py index 8f6ae788a..3b5724f31 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -221,7 +221,7 @@ class Submission(Base): if v and v.poor: return 0 elif self.distinguish_level: - if SITE_NAME == 'rDrama' and kind in ('glowie', 'tilt',): + if SITE_NAME == 'rDrama' and kind in {'glowie', 'tilt',}: return 0 elif SITE_NAME == 'WPD': return 0 @@ -306,7 +306,7 @@ class Submission(Base): if v: sub = self.sub - if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): body += ' disabled ' + if sub in {'furry','vampire','racist','femboy'} and not v.house.lower().startswith(sub): body += ' disabled ' body += f''' onchange="poll_vote_{o.exclusive}('{o.id}', '{self.id}', 'post')"''' else: body += f''' onchange="poll_vote_no_v()"''' diff --git a/files/classes/user.py b/files/classes/user.py index 95dd992cd..e7bb9f8ac 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -318,7 +318,7 @@ class User(Base): @lazy def mods(self, sub): if self.is_suspended_permanently or self.shadowbanned: return False - if self.id in (AEVANN_ID, SNAKES_ID): return True + if self.id in {AEVANN_ID, SNAKES_ID}: return True try: return any(map(lambda x: x.sub == sub, self.sub_mods)) except: @@ -970,7 +970,7 @@ class User(Base): if other.sentto != user.id: return user.admin_level >= PERMS['POST_COMMENT_MODERATION'] # type: ignore elif isinstance(other, Sub): if other.name == 'chudrama': return bool(user) and user.can_see_chudrama - if other.name in ('countryclub','splash_mountain'): return bool(user) and user.can_see_countryclub + if other.name in {'countryclub','splash_mountain'}: return bool(user) and user.can_see_countryclub if other.name == 'masterbaiters': return bool(user) and user.can_see_masterbaiters elif isinstance(other, User): return (user and user.id == other.id) or (user and user.can_see_shadowbanned) or not other.shadowbanned diff --git a/files/helpers/actions.py b/files/helpers/actions.py index dd5b124d7..f80ccac3b 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -389,7 +389,7 @@ def execute_blackjack(v, target, body, type): extra_info = f"reports on {target.permalink}" elif type == 'modmail': extra_info = "modmail" - elif type in ('comment', 'message'): + elif type in {'comment', 'message'}: for id in (CARP_ID, AEVANN_ID): n = Notification(comment_id=target.id, user_id=id) g.db.add(n) diff --git a/files/helpers/media.py b/files/helpers/media.py index ec405eded..aa2989d0a 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -174,11 +174,11 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in path = filename.rsplit('/', 1)[0] kind = path.split('/')[-1] - if kind in ('banners','sidebar'): + if kind in {'banners','sidebar'}: hashes = {} for img in os.listdir(path): - if resize == 400 and img in ('256.webp','585.webp'): continue + if resize == 400 and img in {'256.webp','585.webp'}: continue img_path = f'{path}/{img}' if img_path == filename: continue diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 5a5a4fd6a..20bb454cf 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -87,7 +87,7 @@ def allowed_attributes(tag, name, value): if name == 'preload' and value == 'none': return True if tag == 'p': - if name == 'class' and value in ('mb-0','resizable'): return True + if name == 'class' and value in {'mb-0','resizable'}: return True if tag == 'span': if name == 'data-bs-toggle' and value == 'tooltip': return True diff --git a/files/helpers/twentyone.py b/files/helpers/twentyone.py index 916d3f507..ba9d29a9b 100644 --- a/files/helpers/twentyone.py +++ b/files/helpers/twentyone.py @@ -246,7 +246,7 @@ def handle_payout(gambler, state, game): gambler.pay_account(game.currency, payout) if game.currency == 'coins': - if status in (BlackjackStatus.BLACKJACK, BlackjackStatus.WON): + if status in {BlackjackStatus.BLACKJACK, BlackjackStatus.WON}: distribute_wager_badges(gambler, game.wager, won=True) elif status == BlackjackStatus.LOST: distribute_wager_badges(gambler, game.wager, won=False) diff --git a/files/routes/awards.py b/files/routes/awards.py index 23b724573..415442e68 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -165,7 +165,7 @@ def award_thing(v, thing_type, id): note = request.values.get("note", "").strip() - if SITE == 'rdrama.net' and author.id in (PIZZASHILL_ID,) and v.id not in (AEVANN_ID, SNAKES_ID): + if SITE == 'rdrama.net' and author.id == PIZZASHILL_ID and v.id not in {AEVANN_ID, SNAKES_ID}: abort(403, f"@{author.username} is immune to awards.") if kind == "benefactor" and author.id == v.id: diff --git a/files/routes/casino.py b/files/routes/casino.py index c66722c2f..6688ec8dd 100644 --- a/files/routes/casino.py +++ b/files/routes/casino.py @@ -89,7 +89,7 @@ def pull_slots(v:User): try: currency = request.values.get("currency", "").lower() - if currency not in ('coins', 'marseybux'): raise ValueError() + if currency not in {'coins', 'marseybux'}: raise ValueError() except: abort(400, "Invalid currency (expected 'coins' or 'marseybux').") diff --git a/files/routes/comments.py b/files/routes/comments.py index 4bf5275da..1f18f8aaa 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -126,7 +126,7 @@ def comment(v:User): if posting_to_submission: sub = post_target.sub if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{sub}") - if sub in ('furry','vampire','racist','femboy') and not v.client and not v.house.lower().startswith(sub): + if sub in {'furry','vampire','racist','femboy'} and not v.client and not v.house.lower().startswith(sub): abort(403, f"You need to be a member of House {sub.capitalize()} to comment in /h/{sub}") if level > COMMENT_MAX_DEPTH: abort(400, f"Max comment level is {COMMENT_MAX_DEPTH}") diff --git a/files/routes/polls.py b/files/routes/polls.py index 7b084dece..e0fa4465b 100644 --- a/files/routes/polls.py +++ b/files/routes/polls.py @@ -16,7 +16,7 @@ def vote_option(option_id, v): if not option: abort(404) sub = option.post.sub - if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): + if sub in {'furry','vampire','racist','femboy'} and not v.house.lower().startswith(sub): abort(403, f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}") if option.exclusive == 2: @@ -92,7 +92,7 @@ def vote_option_comment(option_id, v): option = g.db.get(CommentOption, option_id) if not option: abort(404) sub = option.comment.post.sub - if sub in ('furry','vampire','racist','femboy') and not v.house.lower().startswith(sub): + if sub in {'furry','vampire','racist','femboy'} and not v.house.lower().startswith(sub): abort(403, f"You need to be a member of House {sub.capitalize()} to vote on polls in /h/{sub}") if option.exclusive: diff --git a/files/routes/posts.py b/files/routes/posts.py index 31aeae1b1..896addc9f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -493,7 +493,7 @@ def is_repost(): parsed_url = urlparse(url) domain = parsed_url.netloc - if domain in ('old.reddit.com','twitter.com','instagram.com','tiktok.com') and '/search' not in url: + if domain in {'old.reddit.com','twitter.com','instagram.com','tiktok.com'} and '/search' not in url: new_url = ParseResult(scheme="https", netloc=parsed_url.netloc, path=parsed_url.path, @@ -561,7 +561,7 @@ def submit_post(v:User, sub=None): allowed = [x[0] for x in allowed] if v.id not in allowed: return error("You don't have sufficient permissions to post in /h/changelog") - if sub in ('furry','vampire','racist','femboy') and not v.client and not v.house.lower().startswith(sub): + if sub in {'furry','vampire','racist','femboy'} and not v.client and not v.house.lower().startswith(sub): return error(f"You need to be a member of House {sub.capitalize()} to post in /h/{sub}") if sub and sub != 'none': @@ -590,7 +590,7 @@ def submit_post(v:User, sub=None): parsed_url = urlparse(url) domain = parsed_url.netloc - if domain in ('old.reddit.com','twitter.com','instagram.com','tiktok.com') and '/search' not in url: + if domain in {'old.reddit.com','twitter.com','instagram.com','tiktok.com'} and '/search' not in url: new_url = ParseResult(scheme="https", netloc=parsed_url.netloc, path=parsed_url.path, diff --git a/files/routes/reporting.py b/files/routes/reporting.py index 08f36ddf4..7a66b90a4 100644 --- a/files/routes/reporting.py +++ b/files/routes/reporting.py @@ -152,7 +152,7 @@ def move_post(post:Submission, v:User, reason:str) -> Union[bool, str]: if post.author.exiled_from(sub_to): abort(403, f"User is exiled from this {HOLE_NAME}!") - if sub_to in ('furry','vampire','racist','femboy') and not v.client and not post.author.house.lower().startswith(sub_to): + if sub_to in {'furry','vampire','racist','femboy'} and not v.client and not post.author.house.lower().startswith(sub_to): if v.id == post.author_id: abort(403, f"You need to be a member of House {sub_to.capitalize()} to post in /h/{sub_to}") else: diff --git a/files/routes/static.py b/files/routes/static.py index c776dac2c..07643d21f 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -106,7 +106,8 @@ def daily_chart(v:User): @app.get("/paypigs") @admin_level_required(PERMS['VIEW_PATRONS']) def patrons(v): - if AEVANN_ID and v.id not in (AEVANN_ID, CARP_ID, SNAKES_ID): abort(404) + if AEVANN_ID and v.id not in {AEVANN_ID, CARP_ID, SNAKES_ID}: + abort(404) users = g.db.query(User).filter(User.patron > 0).order_by(User.patron.desc(), User.id).all() diff --git a/files/routes/subs.py b/files/routes/subs.py index a27da956e..ce336a1b4 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -239,7 +239,7 @@ def add_mod(v:User, sub): user = get_user(user, v=v, include_shadowbanned=False) - if sub in ('furry','vampire','racist','femboy') and not v.client and not user.house.lower().startswith(sub): + if sub in {'furry','vampire','racist','femboy'} and not v.client and not user.house.lower().startswith(sub): abort(403, f"@{user.username} needs to be a member of House {sub.capitalize()} to be added as a mod there!") existing = g.db.query(Mod).filter_by(user_id=user.id, sub=sub).one_or_none() diff --git a/files/routes/users.py b/files/routes/users.py index be8fb72dc..26bfdcb0d 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -544,7 +544,7 @@ def messagereply(v:User): execute_blackjack(v, c, c.body_html, 'message') execute_under_siege(v, c, c.body_html, 'message') - if user_id and user_id not in (v.id, MODMAIL_ID, bots): + if user_id and user_id not in {v.id, MODMAIL_ID, bots}: notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=user_id).one_or_none() if not notif: notif = Notification(comment_id=c.id, user_id=user_id)