Skip to content

Commit

Permalink
style: Use {} instead of dict()
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Dec 20, 2021
1 parent d3aa60b commit 80b3ab0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 33 deletions.
22 changes: 11 additions & 11 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,17 +577,17 @@ def _run_field_lists(name, summary_table, tables_only):
final_summary_type = sql.SQL('VIEW')

field_list_table = f'{summary_table}_field_list'
format_kwargs = dict(
summary_table=summary_table,
field_list_table=field_list_table,
no_field_list_table=f'{summary_table}_no_field_list',
qualified_primary_keys=[(summary_table, field) for field in table.primary_keys],
no_field_list_type=no_field_list_type,
final_summary_type=final_summary_type,
data_column=table.data_column,
primary_keys=table.primary_keys,
index=f'{field_list_table}_id'
)
format_kwargs = {
'summary_table': summary_table,
'field_list_table': field_list_table,
'no_field_list_table': f'{summary_table}_no_field_list',
'no_field_list_type': no_field_list_type,
'final_summary_type': final_summary_type,
'data_column': table.data_column,
'primary_keys': table.primary_keys,
'qualified_primary_keys': [(summary_table, field) for field in table.primary_keys],
'index': f'{field_list_table}_id',
}

counts_per_path_select = """
SELECT
Expand Down
51 changes: 29 additions & 22 deletions tests/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ def test_command(db, tables_only, field_counts, field_lists, tables, views, filt

def result_dict(statement):
result = db.one(statement)
return dict((column.name, result) for
(column, result) in zip(db.cursor.description, result))
return {column.name: result for column, result in zip(db.cursor.description, result)}

statement = """
SELECT
Expand All @@ -308,17 +307,21 @@ def result_dict(statement):
"""

if filters:
assert result_dict(statement) == {'awards': 1,
'awards_amount': 1,
'awards_id': 1,
'contracts': 0,
'total': 1}
assert result_dict(statement) == {
'awards': 1,
'awards_amount': 1,
'awards_id': 1,
'contracts': 0,
'total': 1,
}
else:
assert result_dict(statement) == {'awards': 213,
'awards_amount': 213,
'awards_id': 213,
'contracts': 0,
'total': 285}
assert result_dict(statement) == {
'awards': 213,
'awards_amount': 213,
'awards_id': 213,
'contracts': 0,
'total': 285,
}

statement = """
SELECT
Expand All @@ -332,17 +335,21 @@ def result_dict(statement):
"""

if filters:
assert result_dict(statement) == {'contracts': 1,
'contracts_amount': 1,
'contracts_id': 1,
'awards': 0,
'total': 4}
assert result_dict(statement) == {
'contracts': 1,
'contracts_amount': 1,
'contracts_id': 1,
'awards': 0,
'total': 4,
}
else:
assert result_dict(statement) == {'contracts': 213,
'contracts_amount': 213,
'contracts_id': 213,
'awards': 0,
'total': 301}
assert result_dict(statement) == {
'contracts': 213,
'contracts_amount': 213,
'contracts_id': 213,
'awards': 0,
'total': 301,
}

# All columns have comments.
assert not db.all("""
Expand Down

0 comments on commit 80b3ab0

Please sign in to comment.