Skip to content

Commit

Permalink
Misc Python 2 syntax removals (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
squeaky-pl authored Feb 17, 2022
1 parent 0aec9d9 commit f68b20a
Show file tree
Hide file tree
Showing 161 changed files with 428 additions and 532 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ ignore=
SFS301,
# Allow .format
SFS201
# https://pypi.org/project/flake8-future-import/
FI1
exclude=migrations/versions
2 changes: 1 addition & 1 deletion bin/backfix-generic-imap-separators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# We previously didn't store IMAP path separators for generic imap accounts.
# This script backfixes the accounts.
from __future__ import print_function


import click

Expand Down
2 changes: 1 addition & 1 deletion bin/check-attachments.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# Check that we can fetch attachments for 99.9% of our syncing accounts.
from __future__ import print_function


from gevent import monkey

Expand Down
1 change: 0 additions & 1 deletion bin/clear-all-heartbeats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

from sys import exit

Expand Down
1 change: 0 additions & 1 deletion bin/clear-heartbeat-status.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

from sys import exit

Expand Down
1 change: 0 additions & 1 deletion bin/correct-autoincrements.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

import click

Expand Down
2 changes: 1 addition & 1 deletion bin/create-db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


import os

Expand Down
2 changes: 1 addition & 1 deletion bin/create-encryption-keys.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


import binascii

Expand Down
1 change: 0 additions & 1 deletion bin/create-event-contact-associations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Create event contact associations for events that don't have any.
"""

from __future__ import division

import click
from sqlalchemy import asc
Expand Down
2 changes: 1 addition & 1 deletion bin/delete-account-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
db_session.commit()
"""
from __future__ import print_function


import time

Expand Down
2 changes: 1 addition & 1 deletion bin/delete-marked-accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Account liveness/status data (in Redis).
"""
from __future__ import absolute_import, print_function


from gevent import monkey

Expand Down
1 change: 0 additions & 1 deletion bin/detect-missing-sync-host.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

import click
from sqlalchemy.orm import load_only
Expand Down
1 change: 0 additions & 1 deletion bin/get-accounts-for-host.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

import click

Expand Down
1 change: 0 additions & 1 deletion bin/get-id.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# Query the id corresponding to a public id and vice-versa.

from __future__ import print_function

import sys

Expand Down
1 change: 0 additions & 1 deletion bin/get-object.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# Query the id corresponding to a public id and vice-versa.

from __future__ import print_function

import sys

Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


from gevent import monkey

Expand Down
2 changes: 1 addition & 1 deletion bin/inbox-start.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


from gevent import monkey

Expand Down
2 changes: 1 addition & 1 deletion bin/migrate-db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


import os

Expand Down
2 changes: 1 addition & 1 deletion bin/mysql-prompt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


import subprocess
import sys
Expand Down
2 changes: 1 addition & 1 deletion bin/purge-transaction-log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
the created_at column)
"""
from __future__ import absolute_import, print_function


from gevent import monkey

Expand Down
1 change: 0 additions & 1 deletion bin/set-desired-host.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

import click

Expand Down
2 changes: 1 addition & 1 deletion bin/set-throttled.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# throttle or unthrottle an account
from __future__ import print_function


import optparse
import sys
Expand Down
2 changes: 1 addition & 1 deletion bin/stamp-db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


import os
import sys
Expand Down
2 changes: 1 addition & 1 deletion bin/syncback-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
also starts up the syncback service.)
"""
from __future__ import print_function


from gevent import monkey

Expand Down
2 changes: 1 addition & 1 deletion bin/syncback-stats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


from gevent import monkey

Expand Down
2 changes: 1 addition & 1 deletion bin/unschedule-account-syncs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


import click

Expand Down
1 change: 0 additions & 1 deletion bin/update-categories.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

from __future__ import print_function

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,5 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function


from inbox.config import config
from inbox.error_handling import maybe_enable_rollbar
Expand Down
1 change: 0 additions & 1 deletion inbox/actions/backends/generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
""" Operations for syncing back local datastore changes to
generic IMAP providers.
"""
Expand Down
2 changes: 0 additions & 2 deletions inbox/api/err.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import sys
import traceback

Expand Down
6 changes: 3 additions & 3 deletions inbox/api/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,13 @@ def filter_event_query(
)

if title is not None:
query = query.filter(event_cls.title.like(u"%{}%".format(title)))
query = query.filter(event_cls.title.like("%{}%".format(title)))

if description is not None:
query = query.filter(event_cls.description.like(u"%{}%".format(description)))
query = query.filter(event_cls.description.like("%{}%".format(description)))

if location is not None:
query = query.filter(event_cls.location.like(u"%{}%".format(location)))
query = query.filter(event_cls.location.like("%{}%".format(location)))

if busy is not None:
query = query.filter(event_cls.busy == busy)
Expand Down
2 changes: 0 additions & 2 deletions inbox/api/srv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import

from flask import Flask, g, jsonify, make_response, request
from flask_restful import reqparse
from sqlalchemy.orm.exc import NoResultFound
Expand Down
6 changes: 3 additions & 3 deletions inbox/api/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def update_thread(thread, request_data, db_session, optimistic):
else:
folder = parse_folder(request_data, db_session, thread.namespace_id)
if request_data:
raise InputError(u"Unexpected attribute: {}".format(list(request_data)[0]))
raise InputError("Unexpected attribute: {}".format(list(request_data)[0]))

if accept_labels:
if labels is not None:
Expand Down Expand Up @@ -128,7 +128,7 @@ def parse_folder(request_data, db_session, namespace_id):
.one()
)
except NoResultFound:
raise InputError(u"The folder {} does not exist".format(folder_public_id))
raise InputError("The folder {} does not exist".format(folder_public_id))


def update_message_folder(message, db_session, category, optimistic):
Expand Down Expand Up @@ -182,7 +182,7 @@ def parse_labels(request_data, db_session, namespace_id):
)
labels.add(category)
except NoResultFound:
raise InputError(u"The label {} does not exist".format(id_))
raise InputError("The label {} does not exist".format(id_))
return labels


Expand Down
12 changes: 5 additions & 7 deletions inbox/api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ def comma_separated_email_list(value, key):
# email address, but in practice nobody does this (and they shouldn't!)

if len(addresses) > 25: # arbitrary limit
raise InputError(u"Too many emails. The current limit is 25")
raise InputError("Too many emails. The current limit is 25")

good_emails = []
for unvalidated_address in addresses:
parsed = address.parse(unvalidated_address, addr_spec_only=True)
if not isinstance(parsed, address.EmailAddress):
raise InputError(
u"Invalid recipient address {}".format(unvalidated_address)
)
raise InputError("Invalid recipient address {}".format(unvalidated_address))
good_emails.append(parsed.address)

return good_emails
Expand Down Expand Up @@ -99,14 +97,14 @@ def offset(value):

def valid_public_id(value):
if "_" in value:
raise InputError(u"Invalid id: {}".format(value))
raise InputError("Invalid id: {}".format(value))

try:
# raise ValueError on malformed public ids
# raise TypeError if an integer is passed in
int(value, 36)
except (TypeError, ValueError):
raise InputError(u"Invalid id: {}".format(value))
raise InputError("Invalid id: {}".format(value))
return value


Expand Down Expand Up @@ -433,7 +431,7 @@ def validate_draft_recipients(draft):
parsed = address.parse(email_address, addr_spec_only=True)
if not isinstance(parsed, address.EmailAddress):
raise InputError(
u"Invalid recipient address {}".format(email_address)
"Invalid recipient address {}".format(email_address)
)


Expand Down
2 changes: 0 additions & 2 deletions inbox/api/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import gevent.monkey

gevent.monkey.patch_all()
Expand Down
2 changes: 0 additions & 2 deletions inbox/auth/google.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import attr

from inbox.basicauth import ImapSupportDisabledError, OAuthError
Expand Down
2 changes: 0 additions & 2 deletions inbox/auth/microsoft.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import attr

from inbox.basicauth import OAuthError
Expand Down
2 changes: 1 addition & 1 deletion inbox/auth/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _get_authenticated_user(self, authorization_code):

session_dict = resp.json()

if u"error" in session_dict:
if "error" in session_dict:
raise OAuthError(session_dict["error"])

userinfo_dict = self._get_user_info(session_dict)
Expand Down
2 changes: 1 addition & 1 deletion inbox/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def token_for_code(self, code):
self.access_token_url, data=urlencode(args), headers=headers
).json()

self.auth_token = resp[u"access_token"]
self.auth_token = resp["access_token"]
return self.auth_token

def is_opensource_api(self):
Expand Down
2 changes: 0 additions & 2 deletions inbox/console.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import sys

import IPython
Expand Down
2 changes: 0 additions & 2 deletions inbox/contacts/algorithms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import division

import datetime
from collections import defaultdict

Expand Down
2 changes: 1 addition & 1 deletion inbox/contacts/icloud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Provide iCloud contacts"""
from __future__ import absolute_import


import contextlib

Expand Down
Loading

0 comments on commit f68b20a

Please sign in to comment.