remove unnecessary [ and ]

pull/216/head
Aevann 2023-10-29 16:22:36 +03:00
parent be65d7c183
commit 4596fd3698
9 changed files with 13 additions and 13 deletions

View File

@ -37,7 +37,7 @@ class Group(Base):
@property
@lazy
def member_ids(self):
return set([x.user_id for x in self.memberships if x.approved_utc])
return set(x.user_id for x in self.memberships if x.approved_utc)
@property
@lazy

View File

@ -442,8 +442,8 @@ class User(Base):
@property
@lazy
def hole_blocks(self):
stealth = set([x[0] for x in g.db.query(Hole.name).filter_by(stealth=True)])
stealth = stealth - set([x[0] for x in g.db.query(StealthHoleUnblock.hole).filter_by(user_id=self.id)])
stealth = set(x[0] for x in g.db.query(Hole.name).filter_by(stealth=True))
stealth = stealth - set(x[0] for x in g.db.query(StealthHoleUnblock.hole).filter_by(user_id=self.id))
if self.chud == 1: stealth = stealth - {'chudrama'}
return list(stealth) + [x[0] for x in g.db.query(HoleBlock.hole).filter_by(user_id=self.id)]
@ -1076,7 +1076,7 @@ class User(Base):
@property
@lazy
def muters(self):
return set([x[0] for x in g.db.query(UserMute.user_id).filter_by(target_id=self.id)])
return set(x[0] for x in g.db.query(UserMute.user_id).filter_by(target_id=self.id))
def get_relationship_count(self, relationship_cls):

View File

@ -182,17 +182,17 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
return 'everyone'
elif i.group(1) == 'jannies':
group = None
member_ids = set([x[0] for x in g.db.query(User.id).filter(User.admin_level > 0, User.id != AEVANN_ID)])
member_ids = set(x[0] for x in g.db.query(User.id).filter(User.admin_level > 0, User.id != AEVANN_ID))
elif i.group(1) == 'followers':
if not followers_ping:
abort(403, f"You can't use !followers in posts!")
group = None
member_ids = set([x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=v.id)])
member_ids = set(x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=v.id))
elif i.group(1) == 'commenters':
if not commenters_ping_post_id:
abort(403, "You can only use !commenters in comments made under posts!")
group = None
member_ids = set([x[0] for x in g.db.query(User.id).join(Comment, Comment.author_id == User.id).filter(Comment.parent_post == commenters_ping_post_id)]) - {v.id}
member_ids = set(x[0] for x in g.db.query(User.id).join(Comment, Comment.author_id == User.id).filter(Comment.parent_post == commenters_ping_post_id)) - {v.id}
else:
group = g.db.get(Group, i.group(1))
if not group: continue

View File

@ -1086,7 +1086,7 @@ from sqlalchemy.orm import scoped_session, sessionmaker
engine = create_engine(environ.get("DATABASE_URL").strip(), connect_args={"options": "-c statement_timeout=5000 -c idle_in_transaction_session_timeout=40000"})
db_session = scoped_session(sessionmaker(bind=engine, autoflush=False))
approved_embed_hosts_for_csp = ' '.join(set([x.split('/')[0] for x in approved_embed_hosts]))
approved_embed_hosts_for_csp = ' '.join(set(x.split('/')[0] for x in approved_embed_hosts))
csp = f"default-src 'none'; frame-ancestors 'none'; form-action 'self'; manifest-src 'self'; worker-src 'self'; base-uri 'self'; font-src 'self'; style-src-elem 'self'; style-src-attr 'unsafe-inline'; style-src 'self' 'unsafe-inline'; script-src-elem 'self' challenges.cloudflare.com; script-src-attr 'none'; script-src 'self' challenges.cloudflare.com; frame-src challenges.cloudflare.com cdpn.io platform.twitter.com rumble.com player.twitch.tv; connect-src 'self' videos.watchpeopledie.tv use1.fptls.com use1.fptls3.com api.fpjs.io; img-src {approved_embed_hosts_for_csp} data:; media-src {approved_embed_hosts_for_csp};"
if not IS_LOCALHOST:
csp += ' upgrade-insecure-requests;'

View File

@ -331,7 +331,7 @@ def _leaderboard_task():
def _process_timer(attr, badge_ids, text, extra_attrs={}):
now = time.time()
users = g.db.query(User).options(load_only(User.id)).filter(1 < attr, attr < now)
uids = set([x.id for x in users])
uids = set(x.id for x in users)
#set user attributes
attr = str(attr).split('.')[1]

View File

@ -98,7 +98,7 @@ def get_account(id, v=None, graceful=False, include_blocks=False):
def get_accounts_dict(ids, v=None, graceful=False):
if not ids: return {}
try:
ids = set([int(id) for id in ids])
ids = set(int(id) for id in ids)
except:
if graceful: return None
abort(400, "User IDs need to be an integer.")

View File

@ -870,7 +870,7 @@ def hole_log(v, hole):
if mod_id:
actions = actions.filter_by(user_id=mod_id)
kinds = set([x.kind for x in actions])
kinds = set(x.kind for x in actions)
if kind: kinds.add(kind)
types2 = {}
for k,val in types.items():

View File

@ -44,7 +44,7 @@ def get_alt_graph_ids(uid):
)
alt_graph_cte = alt_graph_cte.union(alt_graph_cte_inner)
return set([x[0] for x in g.db.query(User.id).filter(User.id == alt_graph_cte.c.user_id, User.id != uid)])
return set(x[0] for x in g.db.query(User.id).filter(User.id == alt_graph_cte.c.user_id, User.id != uid))
def get_alt_graph(uid):
alt_ids = get_alt_graph_ids(uid)

View File

@ -211,7 +211,7 @@ def log(v):
actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED__TYPES))
if admin_id:
actions = actions.filter_by(user_id=admin_id)
kinds = set([x.kind for x in actions])
kinds = set(x.kind for x in actions)
kinds.add(kind)
types2 = {}
for k,val in types.items():