Skip to content

Commit

Permalink
Autoadd # noqa with ruff check . --add-noqa
Browse files Browse the repository at this point in the history
  • Loading branch information
neob91-close committed Dec 11, 2024
1 parent 70b0db8 commit cbbe6eb
Show file tree
Hide file tree
Showing 231 changed files with 1,285 additions and 1,080 deletions.
1 change: 1 addition & 0 deletions bin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# noqa: EXE002
2 changes: 1 addition & 1 deletion bin/backfix-duplicate-categories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
# Duplicate categories were created because of an inadequate unique constraint
# in MySQL. This script deletes duplicate categories with no messages
# associated. If two or more duplicate categories exist with associated
Expand Down
2 changes: 1 addition & 1 deletion bin/backfix-generic-imap-separators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
# We previously didn't store IMAP path separators for generic imap accounts.
# This script backfixes the accounts.

Expand Down
4 changes: 2 additions & 2 deletions bin/check-attachments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
# Check that we can fetch attachments for 99.9% of our syncing accounts.
import concurrent.futures
import datetime
Expand All @@ -20,7 +20,7 @@
NUM_MESSAGES = 10


def process_account(account_id):
def process_account(account_id): # noqa: ANN201
ret = defaultdict(int)

try:
Expand Down
2 changes: 1 addition & 1 deletion bin/clear-all-heartbeats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


from sys import exit
Expand Down
2 changes: 1 addition & 1 deletion bin/clear-db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
import argparse
import sys

Expand Down
2 changes: 1 addition & 1 deletion bin/clear-heartbeat-status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


from sys import exit
Expand Down
2 changes: 1 addition & 1 deletion bin/clear-kv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999

from sys import exit

Expand Down
2 changes: 1 addition & 1 deletion bin/correct-autoincrements.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import click
Expand Down
4 changes: 2 additions & 2 deletions bin/create-db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import os
Expand Down Expand Up @@ -81,7 +81,7 @@ def main(target_hostname, host_ip) -> None:
alembic_ini_filename = os.environ.get(
"ALEMBIC_INI_PATH", "alembic.ini"
)
assert os.path.isfile(
assert os.path.isfile( # noqa: PTH113
alembic_ini_filename
), f"Must have alembic.ini file at {alembic_ini_filename}"
alembic_cfg = alembic.config.Config(alembic_ini_filename)
Expand Down
6 changes: 3 additions & 3 deletions bin/create-encryption-keys.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import binascii
Expand Down Expand Up @@ -36,11 +36,11 @@ def main() -> None:
# so it better exist.
# Update it
try:
with open(secrets_path, "a") as f:
with open(secrets_path, "a") as f: # noqa: PTH123
print(f"Writing keys to secrets config file {secrets_path}")
yaml.dump(data, f, default_flow_style=False)
except OSError:
raise Exception(
raise Exception( # noqa: B904
f"Check file write permissions on config file {secrets_path}"
)

Expand Down
2 changes: 1 addition & 1 deletion bin/create-event-contact-associations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
"""
Create event contact associations for events that don't have any.
"""
Expand Down
4 changes: 2 additions & 2 deletions bin/delete-account-data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
"""
Deletes an account's data permanently.
Expand Down Expand Up @@ -63,7 +63,7 @@ def delete_account_data(account_id, dry_run, yes, throttle) -> int | None:
)
)

answer = raw_input(question).strip().lower()
answer = raw_input(question).strip().lower() # noqa: F821

if answer != "yes":
print("Will NOT delete, goodbye.")
Expand Down
2 changes: 1 addition & 1 deletion bin/delete-marked-accounts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
"""
Searches for accounts that are marked for deletion and deletes
all of their data
Expand Down
4 changes: 2 additions & 2 deletions bin/detect-missing-sync-host.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import click
Expand All @@ -17,7 +17,7 @@ def main() -> None:
was _started_ on a new host without being first stopped on its previous
host.)
"""
""" # noqa: D401
maybe_enable_rollbar()

with global_session_scope() as db_session:
Expand Down
2 changes: 1 addition & 1 deletion bin/get-accounts-for-host.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: EXE001, N999


import click
Expand Down
4 changes: 2 additions & 2 deletions bin/get-id.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
# Query the id corresponding to a public id and vice-versa.


Expand Down Expand Up @@ -40,7 +40,7 @@
def main(type, id, public_id) -> None:
maybe_enable_rollbar()

type = type.lower()
type = type.lower() # noqa: A001

if type not in cls_for_type:
print(f"Error: unknown type '{type}'")
Expand Down
4 changes: 2 additions & 2 deletions bin/get-object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
# Query the id corresponding to a public id and vice-versa.


Expand Down Expand Up @@ -51,7 +51,7 @@
def main(type, id, public_id, account_id, namespace_id, readwrite) -> None:
maybe_enable_rollbar()

type = type.lower()
type = type.lower() # noqa: A001

if type not in cls_for_type:
print(f"Error: unknown type '{type}'")
Expand Down
4 changes: 2 additions & 2 deletions bin/inbox-api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999

import os
import sys
Expand Down Expand Up @@ -49,7 +49,7 @@ def main(prod, config, port) -> None:
maybe_enable_rollbar()

if config is not None:
config_path = os.path.abspath(config)
config_path = os.path.abspath(config) # noqa: PTH100
load_overrides(config_path)

start(port=int(port), use_reloader=not prod)
Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import sys
Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-console.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


from setproctitle import setproctitle
Expand Down
8 changes: 5 additions & 3 deletions bin/inbox-start.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import os
Expand Down Expand Up @@ -83,13 +83,15 @@ def main(prod, enable_profiler, config, process_num) -> None:
if config is not None:
from inbox.util.startup import load_overrides

config_path = os.path.abspath(config)
config_path = os.path.abspath(config) # noqa: PTH100
load_overrides(config_path)

if not prod:
preflight()

total_processes = int(os.environ.get("MAILSYNC_PROCESSES", 1))
total_processes = int(
os.environ.get("MAILSYNC_PROCESSES", 1) # noqa: PLW1508
)

setproctitle.setproctitle(f"sync-engine-{process_num}")

Expand Down
4 changes: 2 additions & 2 deletions bin/migrate-db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import os
Expand All @@ -15,7 +15,7 @@ def main() -> None:
maybe_enable_rollbar()

alembic_ini_filename = os.environ.get("ALEMBIC_INI_PATH", "alembic.ini")
assert os.path.isfile(
assert os.path.isfile( # noqa: PTH113
alembic_ini_filename
), f"Missing alembic.ini file at {alembic_ini_filename}"

Expand Down
4 changes: 2 additions & 2 deletions bin/mysql-prompt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import subprocess
Expand Down Expand Up @@ -51,7 +51,7 @@ def main(shard_num: int | None, execute: str | None, batch: bool) -> None:
creds["db_name"] = shard["SCHEMA_NAME"]
break

for key in creds.keys():
for key in creds.keys(): # noqa: PLC0206
if creds[key] is None:
print(f"Error: {key} is None")
sys.exit(-1)
Expand Down
2 changes: 1 addition & 1 deletion bin/purge-transaction-log.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
"""
Deletes entries in the transaction older than `days_ago` days( as measured by
the created_at column)
Expand Down
2 changes: 1 addition & 1 deletion bin/remove-message-attachments.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
import datetime
import enum
import logging
Expand Down
2 changes: 1 addition & 1 deletion bin/restart-forgotten-accounts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: EXE001, N999

import time

Expand Down
2 changes: 1 addition & 1 deletion bin/set-desired-host.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: EXE001, N999


import click
Expand Down
6 changes: 3 additions & 3 deletions bin/set-throttled.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: EXE001, N999
# throttle or unthrottle an account


Expand Down Expand Up @@ -49,7 +49,7 @@ def main() -> None:
parser.add_option("--unthrottled", action="store_true", default=False)
parser.add_option("--id", action="store", dest="account_id", default=None)
parser.add_option("--stdin", action="store_true", default=False)
options, remainder = parser.parse_args(sys.argv[1:])
options, remainder = parser.parse_args(sys.argv[1:]) # noqa: F841
if all(opt is False for opt in [options.throttled, options.unthrottled]):
print_usage()
sys.exit(-1)
Expand All @@ -67,7 +67,7 @@ def main() -> None:
if len(splat) < 2:
continue

email, id = splat[:2]
email, id = splat[:2] # noqa: A001, F841
options.account_id = id
throttle(options)

Expand Down
4 changes: 2 additions & 2 deletions bin/stamp-db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import os
Expand All @@ -16,7 +16,7 @@ def main(revision_id) -> None:
maybe_enable_rollbar()

alembic_ini_filename = os.environ.get("ALEMBIC_INI_PATH", "alembic.ini")
assert os.path.isfile(
assert os.path.isfile( # noqa: PTH113
alembic_ini_filename
), f"Missing alembic.ini file at {alembic_ini_filename}"

Expand Down
2 changes: 1 addition & 1 deletion bin/sync-single-account.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999

import logging
from threading import BoundedSemaphore
Expand Down
8 changes: 5 additions & 3 deletions bin/syncback-service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999
"""
Run the syncback service separately. You should run this if you run the
API under something like gunicorn. (For convenience, the bin/inbox-api script
Expand Down Expand Up @@ -58,13 +58,15 @@ def main(prod, config, process_num, syncback_id, enable_profiler) -> None:
print("Python", sys.version, file=sys.stderr)

if config is not None:
config_path = os.path.abspath(config)
config_path = os.path.abspath(config) # noqa: PTH100
load_overrides(config_path)
level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL"))
configure_logging(log_level=level)
reconfigure_logging()

total_processes = int(os.environ.get("SYNCBACK_PROCESSES", 1))
total_processes = int(
os.environ.get("SYNCBACK_PROCESSES", 1) # noqa: PLW1508
)

def start():
# Start the syncback service, and just hang out forever
Expand Down
2 changes: 1 addition & 1 deletion bin/syncback-stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999

import click
from sqlalchemy import func
Expand Down
6 changes: 3 additions & 3 deletions bin/unschedule-account-syncs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import click
Expand Down Expand Up @@ -27,7 +27,7 @@ def main(dry_run, number, hostname, process) -> None:
"You have not provided a --number option. This will "
"unschedule ALL syncs on the host. Proceed? [Y/n] "
)
if raw_input(message).strip().lower() == "n":
if raw_input(message).strip().lower() == "n": # noqa: F821
print("Will not proceed")
return

Expand All @@ -38,7 +38,7 @@ def main(dry_run, number, hostname, process) -> None:
hostname
)
)
if raw_input(message).strip().lower() == "n":
if raw_input(message).strip().lower() == "n": # noqa: F821
print("Bailing out")
return

Expand Down
2 changes: 1 addition & 1 deletion bin/update-categories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


import click
Expand Down
2 changes: 1 addition & 1 deletion bin/verify-db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python # noqa: N999


from inbox.config import config
Expand Down
2 changes: 1 addition & 1 deletion inbox/actions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
log = get_logger()


def can_handle_multiple_records(action_name):
def can_handle_multiple_records(action_name): # noqa: ANN201
return action_name == "change_labels"


Expand Down
Loading

0 comments on commit cbbe6eb

Please sign in to comment.