Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
Expand Down
2 changes: 1 addition & 1 deletion parsons/actblue/actblue.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ACTBLUE_API_ENDPOINT = "https://secure.actblue.com/api/v1"


class ActBlue(object):
class ActBlue:
"""
Instantiate class.

Expand Down
2 changes: 1 addition & 1 deletion parsons/action_builder/action_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
API_URL = "https://{subdomain}.actionbuilder.org/api/rest/v1"


class ActionBuilder(object):
class ActionBuilder:
"""
`Args:`
api_token: str
Expand Down
2 changes: 1 addition & 1 deletion parsons/action_kit/action_kit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
logger = logging.getLogger(__name__)


class ActionKit(object):
class ActionKit:
"""
Instantiate the ActionKit class

Expand Down
6 changes: 3 additions & 3 deletions parsons/action_network/action_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import re
import warnings
from typing import Dict, List, Literal, Union
from typing import Literal, Union

from parsons import Table
from parsons.utilities import check_env
Expand All @@ -13,7 +13,7 @@
API_URL = "https://actionnetwork.org/api/v2"


class ActionNetwork(object):
class ActionNetwork:
"""
`Args:`
api_token: str
Expand Down Expand Up @@ -1155,7 +1155,7 @@ def get_person(self, person_id):

def upsert_person(
self,
email_address: Union[str, List[str], List[Dict[str, str]]] = None,
email_address: Union[str, list[str], list[dict[str, str]]] = None,
given_name=None,
family_name=None,
tags=None,
Expand Down
2 changes: 1 addition & 1 deletion parsons/airmeet/airmeet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
AIRMEET_DEFAULT_URI = "https://api-gateway.airmeet.com/prod/"


class Airmeet(object):
class Airmeet:
"""
Instantiate class.

Expand Down
2 changes: 1 addition & 1 deletion parsons/airtable/airtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
logger = logging.getLogger(__name__)


class Airtable(object):
class Airtable:
"""
`Args:`
base_key: str
Expand Down
2 changes: 1 addition & 1 deletion parsons/alchemer/alchemer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def sg_compatibility():
os.environ["ALCHEMER_API_VERSION"] = os.getenv("SURVEYGIZMO_API_VERSION")


class Alchemer(object):
class Alchemer:
"""
Instantiate Alchemer Class

Expand Down
2 changes: 1 addition & 1 deletion parsons/auth0/auth0.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
logger = logging.getLogger(__name__)


class Auth0(object):
class Auth0:
"""
Instantiate the Auth0 class

Expand Down
2 changes: 1 addition & 1 deletion parsons/aws/lambda_distribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_range(self, bucket, key, rangestart, rangeend):
# so e.g. while python returns 2 bytes for data[2:4]
# Range: bytes=2-4 will return 3!! So we subtract 1
response = self.s3.client.get_object(
Bucket=bucket, Key=key, Range="bytes={}-{}".format(rangestart, rangeend - 1)
Bucket=bucket, Key=key, Range=f"bytes={rangestart}-{rangeend - 1}"
)
return response["Body"].read()

Expand Down
4 changes: 2 additions & 2 deletions parsons/aws/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
logger = logging.getLogger(__name__)


class AWSConnection(object):
class AWSConnection:
def __init__(
self,
aws_access_key_id=None,
Expand Down Expand Up @@ -43,7 +43,7 @@ def __init__(
self.session = boto3.Session()


class S3(object):
class S3:
"""
Instantiate the S3 class.

Expand Down
4 changes: 2 additions & 2 deletions parsons/azure/azure_blob_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
logger = logging.getLogger(__name__)


class AzureBlobStorage(object):
class AzureBlobStorage:
"""
Instantiate AzureBlobStorage Class for a given Azure storage account.

Expand Down Expand Up @@ -261,7 +261,7 @@ def _get_content_settings_from_dict(self, kwargs_dict):
kwargs_dict: dict
A dict which should be processed and may have keys for ``ContentSettings``
`Returns:`
Tuple[Optional[ContentSettings], dict]
tuple[Optional[ContentSettings], dict]
Any created settings or ``None`` and the dict with settings keys remvoed
"""

Expand Down
12 changes: 6 additions & 6 deletions parsons/bill_com/bill_com.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from parsons import Table


class BillCom(object):
class BillCom:
"""
`Args:`
user_name: str
Expand All @@ -28,7 +28,7 @@ def __init__(self, user_name, password, org_id, dev_key, api_url):
"orgId": org_id,
"devKey": dev_key,
}
response = requests.post(url="%sLogin.json" % api_url, data=params, headers=self.headers)
response = requests.post(url=f"{api_url}Login.json", data=params, headers=self.headers)
self.dev_key = dev_key
self.api_url = api_url
self.session_id = response.json()["response_data"]["sessionId"]
Expand Down Expand Up @@ -69,14 +69,14 @@ def _post_request(self, data, action, object_name):
"""

if action == "Read":
url = "%sCrud/%s/%s.json" % (self.api_url, action, object_name)
url = f"{self.api_url}Crud/{action}/{object_name}.json"
elif action == "Create":
data["obj"]["entity"] = object_name
url = "%sCrud/%s/%s.json" % (self.api_url, action, object_name)
url = f"{self.api_url}Crud/{action}/{object_name}.json"
elif action == "Send":
url = "%s%s%s.json" % (self.api_url, action, object_name)
url = f"{self.api_url}{action}{object_name}.json"
else:
url = "%s%s/%s.json" % (self.api_url, action, object_name)
url = f"{self.api_url}{action}/{object_name}.json"
payload = self._get_payload(data)
response = requests.post(url=url, data=payload, headers=self.headers)
return response.json()
Expand Down
2 changes: 1 addition & 1 deletion parsons/bloomerang/bloomerang.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
URI_AUTH = "https://crm.bloomerang.co/authorize/"


class Bloomerang(object):
class Bloomerang:
"""
Instantiate Bloomerang class

Expand Down
2 changes: 1 addition & 1 deletion parsons/box/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
DEFAULT_FOLDER_ID = "0"


class Box(object):
class Box:
"""Box is a file storage provider.

`Args:`
Expand Down
2 changes: 1 addition & 1 deletion parsons/braintree/braintree.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ParsonsBraintreeError(Exception):
pass


class Braintree(object):
class Braintree:
"""
Braintree is a payment processor.
`Args:`
Expand Down
2 changes: 1 addition & 1 deletion parsons/capitol_canary/capitol_canary.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
CAPITOL_CANARY_URI = "https://api.phone2action.com/2.0/"


class CapitolCanary(object):
class CapitolCanary:
"""
Instantiate CapitolCanary Class

Expand Down
16 changes: 8 additions & 8 deletions parsons/catalist/catalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tempfile
import time
import urllib
from typing import Dict, List, Optional, Union
from typing import Optional, Union
from zipfile import ZipFile

from parsons.etl import Table
Expand Down Expand Up @@ -118,7 +118,7 @@ def match(
export_filename_suffix: Optional[str] = None,
input_subfolder: Optional[str] = None,
copy_to_sandbox: bool = False,
static_values: Optional[Dict[str, Union[str, int]]] = None,
static_values: Optional[dict[str, Union[str, int]]] = None,
wait: int = 30,
) -> Table:
"""Load table to the Catalist Match API, returns matched table.
Expand Down Expand Up @@ -169,7 +169,7 @@ def upload(
export_filename_suffix: Optional[str] = None,
input_subfolder: Optional[str] = None,
copy_to_sandbox: bool = False,
static_values: Optional[Dict[str, Union[str, int]]] = None,
static_values: Optional[dict[str, Union[str, int]]] = None,
) -> dict:
"""Load table to the Catalist Match API, returns response with job metadata.

Expand Down Expand Up @@ -225,7 +225,7 @@ def upload(
endpoint = "/".join(endpoint_params)

# Assemble query parameters
query_params: Dict[str, Union[str, int]] = {"token": self.connection.token["access_token"]}
query_params: dict[str, Union[str, int]] = {"token": self.connection.token["access_token"]}
if copy_to_sandbox:
query_params["copyToSandbox"] = "true"
if static_values:
Expand All @@ -245,20 +245,20 @@ def upload(

def action(
self,
file_ids: Union[str, List[str]],
file_ids: Union[str, list[str]],
match: bool = False,
export: bool = False,
export_filename_suffix: Optional[str] = None,
copy_to_sandbox: bool = False,
) -> List[dict]:
) -> list[dict]:
"""Perform actions on existing files.

All files must be in Finished status (if the action requested is publish), and
must mapped against the same template. The request will return as soon as the
action has been queued.

`Args:`
file_ids: str or List[str]
file_ids: str or list[str]
one or more file_ids (found in the `id` key of responses from the
upload() or status() methods)
match: bool
Expand Down Expand Up @@ -408,7 +408,7 @@ def validate_table(self, table: Table, template_id: str = "48827") -> None:
"matchbackid",
]

required_columns: List[str] = ["first_name", "last_name"]
required_columns: list[str] = ["first_name", "last_name"]
actual_table_columns = table.columns

unexpected_columns = [
Expand Down
2 changes: 1 addition & 1 deletion parsons/census/census.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logger = logging.getLogger(__name__)


class Census(object):
class Census:
"""
Class that creates a connector to the Census Bureau API
"""
Expand Down
2 changes: 1 addition & 1 deletion parsons/civis/civisclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from parsons.utilities import check_env


class CivisClient(object):
class CivisClient:
"""
Instantiate the Civis class.

Expand Down
2 changes: 1 addition & 1 deletion parsons/community/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
COMMUNITY_API_ENDPOINT = "https://dl.community.com/download/v1/files/"


class Community(object):
class Community:
"""
Instantiate class.

Expand Down
2 changes: 1 addition & 1 deletion parsons/controlshift/controlshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from parsons.utilities.oauth_api_connector import OAuth2APIConnector


class Controlshift(object):
class Controlshift:
"""
Instantiate the Controlshift class. Requires an API Application integration.
For more info on setup, see:
Expand Down
2 changes: 1 addition & 1 deletion parsons/copper/copper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
COPPER_URI = "https://api.prosperworks.com/developer_api/v1"


class Copper(object):
class Copper:
"""
Instantiate Copper Class

Expand Down
2 changes: 1 addition & 1 deletion parsons/crowdtangle/crowdtangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
REQUEST_SLEEP = 10 # CT has a rather agressive 6 requests per minute rate limit.


class CrowdTangle(object):
class CrowdTangle:
"""
Instantiate CrowdTangle Class

Expand Down
14 changes: 6 additions & 8 deletions parsons/databases/discover_database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import List, Optional, Type, Union
from typing import Optional, Union

from parsons.databases.database_connector import DatabaseConnector
from parsons.databases.mysql import MySQL
Expand All @@ -10,7 +10,7 @@

def discover_database(
default_connector: Optional[
Union[Type[DatabaseConnector], List[Type[DatabaseConnector]]]
Union[type[DatabaseConnector], list[type[DatabaseConnector]]]
] = None,
) -> DatabaseConnector:
"""Create an appropriate ``DatabaseConnector`` based on environmental variables.
Expand Down Expand Up @@ -54,7 +54,7 @@ def discover_database(

if len(detected) > 1:
if default_connector is None:
raise EnvironmentError(
raise OSError(
f"Multiple database configurations detected: {detected}."
" Please specify a default connector."
)
Expand All @@ -63,17 +63,15 @@ def discover_database(
for connector in default_connector:
if connector.__name__ in detected:
return connector()
raise EnvironmentError(
f"None of the default connectors {default_connector} were detected."
)
raise OSError(f"None of the default connectors {default_connector} were detected.")
elif default_connector.__name__ in detected:
return default_connector()
else:
raise EnvironmentError(
raise OSError(
f"Default connector {default_connector} not detected. Detected: {detected}."
)

elif detected:
return connectors[detected[0]]()
else:
raise EnvironmentError("Could not find any database configuration.")
raise OSError("Could not find any database configuration.")
2 changes: 1 addition & 1 deletion parsons/databases/postgres/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def copy(
sql = f"""COPY "{table_name}" ("{'","'.join(tbl.columns)}") FROM STDIN CSV HEADER;"""

with self.cursor(connection) as cursor:
cursor.copy_expert(sql, open(tbl.to_csv(), "r"))
cursor.copy_expert(sql, open(tbl.to_csv()))
logger.info(f"{tbl.num_rows} rows copied to {table_name}.")

def table(self, table_name):
Expand Down
Loading
Loading