Merge pull request #4153 from asottile/syntax_warning_filename

Display the filename when encountering `SyntaxWarning`.
This commit is contained in:
Anthony Sottile 2018-10-15 08:40:51 -07:00 committed by GitHub
commit 093e19a7d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -0,0 +1 @@
Display the filename when encountering ``SyntaxWarning``.

View File

@ -398,7 +398,7 @@ def _rewrite_test(config, fn):
finally:
del state._indecode
try:
tree = ast.parse(source)
tree = ast.parse(source, filename=fn.strpath)
except SyntaxError:
# Let this pop up again in the real import.
state.trace("failed to parse: %r" % (fn,))