Skip to content

Commit 889ea97

Browse files
authored
Add ruff flake8-bugbear rules (#1325)
* remove xfail_value_error definition since it was only used once * annotate ruff rules in pyproject.toml * include all pycodestyle errors except line-too-long (E501) -- conflicts with ruff format * add flake8-tidy-imports (TID) * add flake8-import-conventions (ICN) * add flake8-quotes (Q) * add flake8-type-checking (TC) * Add flake8-2020 (YTT) rules * Add flake8-bugbear (B) * additional bugbear fixes after merging main * update success_codes docstrings * fix docstrings again
1 parent f32fa03 commit 889ea97

File tree

35 files changed

+221
-143
lines changed

35 files changed

+221
-143
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
html_sidebars = {"**": ["versions.html"]}
113113

114114
try:
115-
html_context
115+
html_context # noqa: B018
116116
except NameError:
117117
html_context = dict()
118118

parsons/action_network/action_network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ def upsert_person(
12541254
mobile_numbers_field = [{"number": str(mobile_number)}]
12551255
elif isinstance(mobile_number, list):
12561256
if len(mobile_number) > 1:
1257-
raise ("Action Network allows only 1 phone number per activist")
1257+
raise Exception("Action Network allows only 1 phone number per activist")
12581258
if isinstance(mobile_number[0], list):
12591259
mobile_numbers_field = [
12601260
{"number": re.sub("[^0-9]", "", cell)} for cell in mobile_number
@@ -1276,7 +1276,7 @@ def upsert_person(
12761276
mobile_numbers_field = mobile_number
12771277

12781278
if not email_addresses_field and not mobile_numbers_field:
1279-
raise (
1279+
raise Exception(
12801280
"Either email_address or mobile_number is required and can be formatted "
12811281
"as a string, list of strings, a dictionary, a list of dictionaries, or "
12821282
"(for mobile_number only) an integer or list of integers"

parsons/auth0/auth0.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def upsert_user(
8282
username=None,
8383
given_name=None,
8484
family_name=None,
85-
app_metadata={},
86-
user_metadata={},
85+
app_metadata=None,
86+
user_metadata=None,
8787
connection="Username-Password-Authentication",
8888
):
8989
"""
@@ -106,6 +106,10 @@ def upsert_user(
106106
Requests Response object
107107
"""
108108

109+
if user_metadata is None:
110+
user_metadata = {}
111+
if app_metadata is None:
112+
app_metadata = {}
109113
obj = {
110114
"email": email.lower(),
111115
"username": username,

parsons/aws/aws_async.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def event_command(event, context):
4646

4747
def run(
4848
func,
49-
args=[],
50-
kwargs={},
49+
args=None,
50+
kwargs=None,
5151
service="lambda",
5252
capture_response=False,
5353
remote_aws_lambda_function_name=None,
@@ -56,6 +56,10 @@ def run(
5656
func_class_init_kwargs=None,
5757
**task_kwargs,
5858
):
59+
if kwargs is None:
60+
kwargs = {}
61+
if args is None:
62+
args = []
5963
lambda_function_name = remote_aws_lambda_function_name or os.environ.get(
6064
"AWS_LAMBDA_FUNCTION_NAME"
6165
)

parsons/box/box.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,6 @@ def get_item_id(self, path, base_folder_id=DEFAULT_FOLDER_ID) -> str:
399399
# recursion, just pass it on up.
400400
except ValueError as e:
401401
if base_folder_id == DEFAULT_FOLDER_ID:
402-
raise ValueError(f'{e}: "{path}"')
402+
raise ValueError(f'{e}: "{path}"') from e
403403
else:
404404
raise

parsons/copper/copper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ def process_json(self, json_blob, obj_type, tidy=False):
284284
for column in list_cols:
285285
# Check for nested data
286286
list_rows = obj_table.select_rows(
287-
lambda row: isinstance(row[column], list)
288-
and any(isinstance(x, dict) for x in row[column])
287+
lambda row: isinstance(row[column], list) # noqa: B023
288+
and any(isinstance(x, dict) for x in row[column]) # noqa: B023
289289
)
290290
# Add separate long table for each column with nested data
291291
if list_rows.num_rows > 0:

parsons/databases/alchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ def split_table_name(full_table_name):
7777
schema, table = full_table_name.split(".")
7878
except ValueError as e:
7979
if "too many values to unpack" in str(e):
80-
raise ValueError(f"Invalid database table {full_table_name}")
80+
raise ValueError(f"Invalid database table {full_table_name}") from e
8181

8282
return schema, table

parsons/databases/postgres/postgres_create_statement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def generate_data_types(self, table):
108108
cont = petl.records(table.table)
109109

110110
# Populate empty values for the columns
111-
for col in table.columns:
111+
for _col in table.columns:
112112
longest.append(0)
113113
type_list.append("")
114114

parsons/databases/redshift/rs_create_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def generate_data_types(self, table):
107107
cont = petl.records(table.table)
108108

109109
# Populate empty values for the columns
110-
for col in table.columns:
110+
for _col in table.columns:
111111
longest.append(0)
112112
type_list.append("")
113113

parsons/databases/redshift/rs_table_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def split_full_table_name(full_table_name):
755755
schema, table = full_table_name.split(".")
756756
except ValueError as e:
757757
if "too many values to unpack" in str(e):
758-
raise ValueError(f"Invalid Redshift table {full_table_name}")
758+
raise ValueError(f"Invalid Redshift table {full_table_name}") from e
759759

760760
return schema, table
761761

0 commit comments

Comments
 (0)