Skip to content

Commit

Permalink
Fix hash comment removal in GraphQL schemas
Browse files Browse the repository at this point in the history
The regex used to remove hash comments originally used the re.MULTILINE
flag. Now that that flag is gone, the '$' in the regex no longer makes
sense (it only matches the end of the file). The regex also had a
dangling '\1' backreference that has been removed as well.

I recently federated some additional GraphQL types and converted
docstrings to hash comments in the process, at which point I noticed the
linter wasn't removing comments as expected.

Issue: none

Test plan:
ka-lint services/*/*.graphql

Auditors: csilvers
  • Loading branch information
dnerdy committed Apr 7, 2020
1 parent 32481da commit b7c392b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ def process(self, f, contents_of_f):
contents_without_comments = re.sub(
r'""".*?"""', "", contents_of_f, flags=re.DOTALL)
contents_without_comments = re.sub(
r'#.*$', r"\1", contents_without_comments)
r'#.*', '', contents_without_comments)

# Now find undefined types and add them in.
new_type_re = re.compile(
Expand Down

0 comments on commit b7c392b

Please sign in to comment.