fix flake8 E713 (test-for-membership)

This commit is contained in:
Pavol Rusnak 2023-01-21 15:07:40 +00:00
parent f6bd8684d3
commit eba7319808
No known key found for this signature in database
GPG key ID: 91F3B339B9A02A3D
9 changed files with 11 additions and 11 deletions

View file

@ -228,7 +228,7 @@ def lnencode(addr, privkey):
# both. # both.
if "d" in tags_set and "h" in tags_set: if "d" in tags_set and "h" in tags_set:
raise ValueError("Cannot include both 'd' and 'h'") raise ValueError("Cannot include both 'd' and 'h'")
if not "d" in tags_set and not "h" in tags_set: if "d" not in tags_set and "h" not in tags_set:
raise ValueError("Must include either 'd' or 'h'") raise ValueError("Must include either 'd' or 'h'")
# We actually sign the hrp, then data (padded to 8 bits with zeroes). # We actually sign the hrp, then data (padded to 8 bits with zeroes).

View file

@ -449,7 +449,7 @@ async def check_admin_settings():
def update_cached_settings(sets_dict: dict): def update_cached_settings(sets_dict: dict):
for key, value in sets_dict.items(): for key, value in sets_dict.items():
if not key in readonly_variables + transient_variables: if key not in readonly_variables:
try: try:
setattr(settings, key, value) setattr(settings, key, value)
except: except:

View file

@ -137,7 +137,7 @@ async def extensions_install(
"dependencies": ext.dependencies, "dependencies": ext.dependencies,
"isInstalled": ext.id in installed_exts_ids, "isInstalled": ext.id in installed_exts_ids,
"isAvailable": ext.id in all_extensions, "isAvailable": ext.id in all_extensions,
"isActive": not ext.id in inactive_extensions, "isActive": ext.id not in inactive_extensions,
"latestRelease": dict(ext.latest_release) "latestRelease": dict(ext.latest_release)
if ext.latest_release if ext.latest_release
else None, else None,

View file

@ -135,7 +135,7 @@ class Database(Compat):
if value is None: if value is None:
return None return None
f = "%Y-%m-%d %H:%M:%S.%f" f = "%Y-%m-%d %H:%M:%S.%f"
if not "." in value: if "." not in value:
f = "%Y-%m-%d %H:%M:%S" f = "%Y-%m-%d %H:%M:%S"
return time.mktime(datetime.datetime.strptime(value, f).timetuple()) return time.mktime(datetime.datetime.strptime(value, f).timetuple())

View file

@ -245,7 +245,7 @@ async def check_user_exists(usr: UUID4) -> User:
async def check_admin(usr: UUID4) -> User: async def check_admin(usr: UUID4) -> User:
user = await check_user_exists(usr) user = await check_user_exists(usr)
if user.id != settings.super_user and not user.id in settings.lnbits_admin_users: if user.id != settings.super_user and user.id not in settings.lnbits_admin_users:
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.UNAUTHORIZED, status_code=HTTPStatus.UNAUTHORIZED,
detail="User not authorized. No admin privileges.", detail="User not authorized. No admin privileges.",

View file

@ -467,7 +467,7 @@ class InstalledExtensionMiddleware:
self.app = app self.app = app
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if not "path" in scope: if "path" not in scope:
await self.app(scope, receive, send) await self.app(scope, receive, send)
return return

View file

@ -128,7 +128,7 @@ def unshorten_lnurl_query(query: dict) -> Dict[str, str]:
long_tag = rules["tags"][tag] long_tag = rules["tags"][tag]
new_query["tag"] = long_tag new_query["tag"] = long_tag
tag = long_tag tag = long_tag
if not tag in rules["params"]: if tag not in rules["params"]:
raise LnurlValidationError(f'Unknown tag: "{tag}"') raise LnurlValidationError(f'Unknown tag: "{tag}"')
for key in query: for key in query:
if key in rules["params"][str(tag)]: if key in rules["params"][str(tag)]:
@ -142,7 +142,7 @@ def unshorten_lnurl_query(query: dict) -> Dict[str, str]:
# Unshorten general keys: # Unshorten general keys:
short_key = key short_key = key
long_key = rules["query"][short_key] long_key = rules["query"][short_key]
if not long_key in new_query: if long_key not in new_query:
if short_key in query: if short_key in query:
new_query[long_key] = query[short_key] new_query[long_key] = query[short_key]
else: else:

View file

@ -42,7 +42,7 @@ async def api_bleskomat_lnurl(req: Request):
# The API key ID, nonce, and tag should be present in the query string. # The API key ID, nonce, and tag should be present in the query string.
for field in ["id", "nonce", "tag"]: for field in ["id", "nonce", "tag"]:
if not field in query: if field not in query:
raise LnurlHttpError( raise LnurlHttpError(
f'Failed API key signature check: Missing "{field}"', f'Failed API key signature check: Missing "{field}"',
HTTPStatus.BAD_REQUEST, HTTPStatus.BAD_REQUEST,
@ -105,7 +105,7 @@ async def api_bleskomat_lnurl(req: Request):
# No signature provided. # No signature provided.
# Treat as "action" callback. # Treat as "action" callback.
if not "k1" in query: if "k1" not in query:
raise LnurlHttpError("Missing secret", HTTPStatus.BAD_REQUEST) raise LnurlHttpError("Missing secret", HTTPStatus.BAD_REQUEST)
secret = query["k1"] secret = query["k1"]

View file

@ -85,7 +85,7 @@ class BleskomatLnurl(BaseModel):
# Perform tag-specific checks. # Perform tag-specific checks.
if tag == "withdrawRequest": if tag == "withdrawRequest":
for field in ["pr"]: for field in ["pr"]:
if not field in query: if field not in query:
raise LnurlValidationError(f'Missing required parameter: "{field}"') raise LnurlValidationError(f'Missing required parameter: "{field}"')
# Check the bolt11 invoice(s) provided. # Check the bolt11 invoice(s) provided.
pr = query["pr"] pr = query["pr"]