Skip to content

Commit

Permalink
Remove redundant set copy and sort another set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Prescod committed May 16, 2020
1 parent 20f53c4 commit 354f671
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions snowfakery/generate_mapping_from_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def find_record_type_field(fields, context_name):
if not record_type_fields:
return None
elif len(record_type_fields) > 1:
raise DataGenError(f"Only one RecordType field allowed: {context_name}")
raise DataGenError(
f"Only one RecordType field allowed: {context_name}", None, None
)
elif record_type_fields[0].name != "RecordType":
raise DataGenNameError(
"Recordtype field needs this capitalization: RecordType", None, None
Expand Down Expand Up @@ -60,7 +62,7 @@ def generate_record_type_pseudo_tables(summary):
record_type_pseudo_table.record_type = record_type_name

# copy over the dependencies from the real table
for dependency in sorted(summary.intertable_dependencies.copy()):
for dependency in sorted(summary.intertable_dependencies):
if dependency.table_name_from == real_table_name:
summary.intertable_dependencies.add(
Dependency(record_type_name, *dependency[1:])
Expand Down Expand Up @@ -100,7 +102,7 @@ def _table_is_free(table_name, dependencies, sorted_tables):
usage examples.
"""
tables_this_table_depends_upon = dependencies.get(table_name, {})
for dependency in tables_this_table_depends_upon.copy():
for dependency in sorted(tables_this_table_depends_upon):
if dependency.table_name_to in sorted_tables:
tables_this_table_depends_upon.remove(dependency)

Expand Down Expand Up @@ -151,9 +153,9 @@ def mappings_from_sorted_tables(

if "RecordType" in table.fields:
fielddef = table.fields["RecordType"].definition
if not getattr(fielddef, "definition"):
if not getattr(fielddef, "definition", None):
raise DataGenError(
"Record type definitions must be simple, not computed"
"Record type definitions must be simple, not computed", None, None
)
record_type = fielddef.definition
filters = [f"RecordType = '{record_type}'"]
Expand Down

0 comments on commit 354f671

Please sign in to comment.