Skip to content

Commit ecbf34f

Browse files
committed
fix: only do header mappings for add suggestions, and check ignores again after mapping
1 parent d1e538b commit ecbf34f

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

filter_include_changes.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,27 @@ def filter_changes(
125125
if header in header_mappings and header_mappings[header] in pending_changes[filename]:
126126
if pending_changes[filename][header][0] is IncludeChange.REMOVE:
127127
continue
128+
129+
try:
130+
header = header_mappings[header]
131+
except KeyError:
132+
# Confirm the header is in the inverse mapping,
133+
# which is the only way we should end up here
134+
assert header in inverse_header_mappings
135+
136+
# Check ignores again now that we've mapped the header
137+
ignore_edge = (filename, header) in ignores.add.edges
138+
ignore_include = header in ignores.add.headers
139+
140+
if ignore_edge or ignore_include:
141+
continue
128142
elif change_type is IncludeChange.REMOVE and header in inverse_header_mappings:
129143
# Look for a corresponding add which would cancel out
130144
if header in inverse_header_mappings and inverse_header_mappings[header] in pending_changes[filename]:
131145
if pending_changes[filename][header][0] is IncludeChange.ADD:
132146
continue
133147

134-
yield (change_type.value, line, filename, header_mappings[header], *_)
148+
yield (change_type.value, line, filename, header, *_)
135149

136150

137151
def main():

0 commit comments

Comments
 (0)