Skip to content

Commit

Permalink
Bump black from 19.10b0 to 23.11.0 in /requirements (#551)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Squeaky <[email protected]>
  • Loading branch information
dependabot[bot] and squeaky-pl authored Nov 21, 2023
1 parent 4a8b9be commit c064bf8
Show file tree
Hide file tree
Showing 111 changed files with 463 additions and 271 deletions.
2 changes: 1 addition & 1 deletion bin/contact-search-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
@click.option("-c", "--config", default=None, help="Path to JSON configuration file.")
def main(prod, config):
""" Launch the contact search index service. """
"""Launch the contact search index service."""
level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL"))
configure_logging(log_level=level)

Expand Down
1 change: 0 additions & 1 deletion bin/detect-missing-sync-host.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def main():
)
.filter(Account.sync_state == "stopped")
):

if acc.desired_sync_host is not None:
print(
"account {} assigned to {} but has sync_state 'stopped'"
Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
@click.option("-c", "--config", default=None, help="Path to JSON configuration file.")
@click.option("-p", "--port", default=5555, help="Port to run flask app on.")
def main(prod, start_syncback, enable_tracer, config, port, enable_profiler):
""" Launch the Nylas API service. """
"""Launch the Nylas API service."""
level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL"))
configure_logging(log_level=level)

Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
help="Manually specify the provider instead of trying to detect it",
)
def main(email_address, reauth, target, provider):
""" Auth an email account. """
"""Auth an email account."""
preflight()

maybe_enable_rollbar()
Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-console.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)
@click.option("-c", "--client", is_flag=True, help="Start a repl with an APIClient")
def console(email_address, client):
""" REPL for Nylas. """
"""REPL for Nylas."""
maybe_enable_rollbar()

if client:
Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-start.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"can be used to avoid memory leaks.",
)
def main(prod, enable_tracer, enable_profiler, config, process_num, exit_after):
""" Launch the Nylas sync service. """
"""Launch the Nylas sync service."""
level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL"))
configure_logging(log_level=level)
reconfigure_logging()
Expand Down
2 changes: 1 addition & 1 deletion bin/syncback-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
help="Enables the CPU profiler web API",
)
def main(prod, config, process_num, syncback_id, enable_tracer, enable_profiler):
""" Launch the actions syncback service. """
"""Launch the actions syncback service."""
setproctitle("syncback-{}".format(process_num))

maybe_enable_rollbar()
Expand Down
2 changes: 1 addition & 1 deletion bin/syncback-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@click.command()
def main():
""" Generate per-shard and per-namespace breakdowns of syncback queue
"""Generate per-shard and per-namespace breakdowns of syncback queue
lengths.
"""
Expand Down
4 changes: 2 additions & 2 deletions inbox/actions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def delete_label(crispin_client, account_id, category_id):


def save_draft(crispin_client, account_id, message_id, args):
""" Sync a new draft back to the remote backend. """
"""Sync a new draft back to the remote backend."""
with session_scope(account_id) as db_session:
message = db_session.query(Message).get(message_id)
version = args.get("version")
Expand All @@ -131,7 +131,7 @@ def save_draft(crispin_client, account_id, message_id, args):


def update_draft(crispin_client, account_id, message_id, args):
""" Sync an updated draft back to the remote backend. """
"""Sync an updated draft back to the remote backend."""
with session_scope(account_id) as db_session:
message = db_session.query(Message).get(message_id)
version = args.get("version")
Expand Down
10 changes: 5 additions & 5 deletions inbox/api/err.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_request_uid(headers):


def log_exception(exc_info, **kwargs):
""" Add exception info to the log context for the request.
"""Add exception info to the log context for the request.
We do not log in a separate log statement in order to make debugging
easier. As a bonus, this reduces log volume somewhat.
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self, message):


class AccountInvalidError(APIException):
""" Raised when an account's credentials are not valid. """
"""Raised when an account's credentials are not valid."""

status_code = 403
message = (
Expand All @@ -90,7 +90,7 @@ class AccountInvalidError(APIException):


class AccountStoppedError(APIException):
""" Raised when an account has been stopped. """
"""Raised when an account has been stopped."""

status_code = 403
message = (
Expand All @@ -101,14 +101,14 @@ class AccountStoppedError(APIException):


class AccountDoesNotExistError(APIException):
""" Raised when an account does not exist (for example, if it was deleted). """
"""Raised when an account does not exist (for example, if it was deleted)."""

status_code = 404
message = "The account does not exist."


def err(http_code, message, **kwargs):
""" Handle unexpected errors, including sending the traceback to Rollbar. """
"""Handle unexpected errors, including sending the traceback to Rollbar."""
log_exception(sys.exc_info(), user_error_message=message, **kwargs)
resp = {"type": "api_error", "message": message}
resp.update(kwargs)
Expand Down
4 changes: 0 additions & 4 deletions inbox/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def threads(
view,
db_session,
):

if view == "count":
query = db_session.query(func.count(Thread.id))
elif view == "ids":
Expand Down Expand Up @@ -469,7 +468,6 @@ def files(
view,
db_session,
):

if view == "count":
query = db_session.query(func.count(Block.id))
elif view == "ids":
Expand Down Expand Up @@ -524,7 +522,6 @@ def filter_event_query(
location,
busy,
):

query = query.filter(event_cls.namespace_id == namespace_id).filter(
event_cls.deleted_at.is_(None)
)
Expand Down Expand Up @@ -631,7 +628,6 @@ def events(
show_cancelled,
db_session,
):

query = db_session.query(Event)

if not expand_recurring:
Expand Down
5 changes: 4 additions & 1 deletion inbox/api/kellogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def format_phone_numbers(phone_numbers):
formatted_phone_numbers = []
for number in phone_numbers:
formatted_phone_numbers.append(
{"type": number.type, "number": number.number,}
{
"type": number.type,
"number": number.number,
}
)
return formatted_phone_numbers

Expand Down
9 changes: 6 additions & 3 deletions inbox/api/ns_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ def status():
else:
account.throttled = False
return g.encoder.jsonify(
{"sync_status": account.sync_status, "throttled": account.throttled,}
{
"sync_status": account.sync_status,
"throttled": account.throttled,
}
)


Expand Down Expand Up @@ -498,7 +501,7 @@ def thread_api_update(public_id):
#
@app.route("/threads/<public_id>", methods=["DELETE"])
def thread_api_delete(public_id):
""" Moves the thread to the trash """
"""Moves the thread to the trash"""
raise NotImplementedError


Expand Down Expand Up @@ -1248,7 +1251,7 @@ def event_update_api(public_id):
notify_participants=notify_participants,
)

if len(json.dumps(kwargs)) > 2 ** 16 - 12:
if len(json.dumps(kwargs)) > 2**16 - 12:
raise InputError("Event update too big --- please break it in parts.")

if event.calendar != account.emailed_events_calendar:
Expand Down
11 changes: 5 additions & 6 deletions inbox/api/srv.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def handle_input_error(error):


def default_json_error(ex):
""" Exception -> flask JSON responder """
"""Exception -> flask JSON responder"""
logger = get_logger()
logger.error("Uncaught error thrown by Flask/Werkzeug", exc_info=ex)
response = jsonify(message=str(ex), type="api_error")
Expand All @@ -63,7 +63,7 @@ def default_json_error(ex):

@app.before_request
def auth():
""" Check for account ID on all non-root URLS """
"""Check for account ID on all non-root URLS"""
if (
request.path == "/"
or request.path.startswith("/accounts")
Expand All @@ -73,7 +73,6 @@ def auth():
return

if not request.authorization or not request.authorization.username:

AUTH_ERROR_MSG = (
"Could not verify access credential.",
401,
Expand Down Expand Up @@ -129,7 +128,7 @@ def finish(response):

@app.route("/accounts/", methods=["GET"])
def ns_all():
""" Return all namespaces """
"""Return all namespaces"""
# We do this outside the blueprint to support the case of an empty
# public_id. However, this means the before_request isn't run, so we need
# to make our own session
Expand Down Expand Up @@ -244,7 +243,7 @@ def _get_account_data_for_microsoft_account(

@app.route("/accounts/", methods=["POST"])
def create_account():
""" Create a new account """
"""Create a new account"""
data = request.get_json(force=True)

auth_handler: Union[GenericAuthHandler, GoogleAuthHandler, MicrosoftAuthHandler]
Expand Down Expand Up @@ -310,7 +309,7 @@ def modify_account(namespace_public_id):

@app.route("/accounts/<namespace_public_id>/", methods=["DELETE"])
def delete_account(namespace_public_id):
""" Mark an existing account for deletion. """
"""Mark an existing account for deletion."""
try:
with global_session_scope() as db_session:
namespace = (
Expand Down
5 changes: 4 additions & 1 deletion inbox/api/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def update_message(message, request_data, db_session, optimistic):
def update_thread(thread, request_data, db_session, optimistic):
accept_labels = thread.namespace.account.provider == "gmail"

unread, starred, = parse_flags(request_data)
(
unread,
starred,
) = parse_flags(request_data)
if accept_labels:
labels = parse_labels(request_data, db_session, thread.namespace_id)
else:
Expand Down
4 changes: 3 additions & 1 deletion inbox/auth/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def authenticate_imap_connection(self, account, conn):
except IMAPClient.Error as exc:
if auth_is_invalid(exc):
log.error(
"IMAP login failed", account_id=account.id, error=exc,
"IMAP login failed",
account_id=account.id,
error=exc,
)
raise ValidationError(exc)
elif auth_requires_app_password(exc):
Expand Down
4 changes: 3 additions & 1 deletion inbox/auth/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ def authenticate_imap_connection(self, account: OAuthAccount, conn: IMAPClient):
raise exc from original_exc

log.warning(
"Error during IMAP XOAUTH2 login", account_id=account.id, error=exc,
"Error during IMAP XOAUTH2 login",
account_id=account.id,
error=exc,
)
if not isinstance(exc, ImapSupportDisabledError):
raise # Unknown IMAPClient error, reraise
Expand Down
3 changes: 2 additions & 1 deletion inbox/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def create_imap_connection(host, port, use_timeout=True):
conn.starttls(context)
except Exception:
log.warning(
"STARTTLS supported but failed.", exc_info=True,
"STARTTLS supported but failed.",
exc_info=True,
)
raise
else:
Expand Down
4 changes: 2 additions & 2 deletions inbox/contacts/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def _get_participants(msg, excluded_emails=None):

# Not really an algorithm, but it seemed reasonable to put this here?
def is_stale(last_updated, lifespan=14):
""" last_updated is a datetime.datetime object
lifespan is measured in days
"""last_updated is a datetime.datetime object
lifespan is measured in days
"""
if last_updated is None:
return True
Expand Down
13 changes: 8 additions & 5 deletions inbox/contacts/carddav.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@


def supports_carddav(url):
""" Basic verification that the endpoint supports CardDav
"""
"""Basic verification that the endpoint supports CardDav"""
response = requests.request(
"OPTIONS", url, headers={"User-Agent": USER_AGENT, "Depth": "1"}
)
Expand All @@ -42,7 +41,7 @@ def supports_carddav(url):


class CardDav:
""" NOTE: Only supports iCloud for now """
"""NOTE: Only supports iCloud for now"""

def __init__(self, email_address, password, base_url):
self.session = requests.Session()
Expand All @@ -52,7 +51,7 @@ def __init__(self, email_address, password, base_url):
self.base_url = base_url

def get_principal_url(self):
""" Use PROPFIND method to find the `principal` carddav url """
"""Use PROPFIND method to find the `principal` carddav url"""

payload = """
<A:propfind xmlns:A='DAV:'>
Expand Down Expand Up @@ -119,7 +118,11 @@ def get_cards(self, url):
</C:addressbook-query>
"""

response = self.session.request("REPORT", url, data=payload,)
response = self.session.request(
"REPORT",
url,
data=payload,
)

response.raise_for_status()
return response.content
Expand Down
1 change: 0 additions & 1 deletion inbox/contacts/icloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def get_items(self, sync_from_dt=None, max_results=100000):

all_contacts = []
for refprop in root.iterchildren():

try:
cardstring = refprop[1][0][1].text
except IndexError:
Expand Down
Loading

0 comments on commit c064bf8

Please sign in to comment.