Skip to content

[Python] Update list of Python files without .py suffix in .pep8 file #1216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2016
Merged

[Python] Update list of Python files without .py suffix in .pep8 file #1216

merged 1 commit into from
Feb 15, 2016

Conversation

practicalswift
Copy link
Contributor

Changes:

  • Add ld (test/Driver/Inputs/filelists/ld)
  • Remove pre-commit-benchmark (deleted)

@jrose-apple
Copy link
Contributor

:-/ It seems wrong to have to update this every time we need a new helper tool for tests. Is there a way to get it to detect files from their #! line? Maybe "files in test/* and utils/* with no extension with a first line matching #!.+python"?

@practicalswift
Copy link
Contributor Author

@jrose-apple Yes, I agree that is problematic.

Unfortunately the .pep8 format is quite limited so I'm afraid the filename directive is the only inclusion mechanism available.

The way I'm finding Python files without a .py suffix is almost exactly what you suggested :-) This is what I'm using in my local "check-Swift-repo-consistency"-routine:

$ git grep '#!.*python' | cut -f1 -d: | sort | egrep -v '.py$' | sort
docs/scripts/ns-html2rst
test/Driver/Inputs/filelists/ld
utils/build-script
utils/gyb
utils/line-directive
utils/recursive-lipo
utils/submit-benchmark-results
utils/update-checkout
utils/viewcfg

Turns out test/Driver/Inputs/filelists/ld is the only Python file under test/ that is missing a .py extension.

Possible solutions:

  • Should we simply skip linting Python files without .py suffix under test/?
  • If not, should we standardize on having a .py suffix for all Python files under test/?

@jrose-apple
Copy link
Contributor

Well, the reason ld doesn't is because it's acting like the real ld, but I suppose we could change the test so that it symlinks it into a temporary directory (ln -s %S/Inputs/filelists/ld.py %t/ld) rather than just pointing at the existing one.

@practicalswift
Copy link
Contributor Author

@jrose-apple Yes, ld is a special case. The symlink solution sounds smart. Please let me know if you want me to make any changes to this PR to make it merge:able :-)

@jrose-apple
Copy link
Contributor

Okay, I moved ld to fake-ld.py in 839dfc0. Everything else seems reasonable.

@practicalswift
Copy link
Contributor Author

@jrose-apple PR updated accordingly. Let me know if any further changes are needed :-)

@jrose-apple
Copy link
Contributor

Ah, now there are conflicts because of your other change. Can you rebase and try again?

@practicalswift
Copy link
Contributor Author

@jrose-apple Rebased :-)

@jrose-apple
Copy link
Contributor

I hate to keep bugging you but you snuck the "E114" change into this commit. Was that intentional?

@practicalswift
Copy link
Contributor Author

@jrose-apple Good you noticed that :-) That change belongs in #1292, so removed it from this PR. Also added the remaining missing files. Let me know if any changes are needed :-)

@practicalswift
Copy link
Contributor Author

Rebased again :-)

@jrose-apple
Copy link
Contributor

…are the .in files valid Python? Valid enough to check with pep8? I mean, it's too bad that we wouldn't get any checking otherwise, but…

@practicalswift
Copy link
Contributor Author

@jrose-apple Yes, they are all passing flake8. They are 100 % Python with "@PATH_TO_DRIVER_LIBRARY@" strings as the only magic :-)

$ flake8 ./benchmark/scripts/Benchmark_DTrace.in ./benchmark/scripts/Benchmark_GuardMalloc.in ./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in
$ head -1 ./benchmark/scripts/Benchmark_DTrace.in ./benchmark/scripts/Benchmark_GuardMalloc.in ./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in
==> ./benchmark/scripts/Benchmark_DTrace.in <==
#!/usr/bin/env python

==> ./benchmark/scripts/Benchmark_GuardMalloc.in <==
#!/usr/bin/env python

==> ./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in <==
#!/usr/bin/env python
$ egrep '@.*@' ./benchmark/scripts/Benchmark_DTrace.in ./benchmark/scripts/Benchmark_GuardMalloc.in ./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in
./benchmark/scripts/Benchmark_DTrace.in:DRIVER_LIBRARY_PATH = "@PATH_TO_DRIVER_LIBRARY@"
./benchmark/scripts/Benchmark_GuardMalloc.in:sys.path.append("@PATH_TO_DRIVER_LIBRARY@")
./benchmark/scripts/Benchmark_RuntimeLeaksRunner.in:sys.path.append("@PATH_TO_DRIVER_LIBRARY@")

@shahmishal
Copy link
Member

@swift-ci Please test

@practicalswift
Copy link
Contributor Author

@shahmishal Build seems to have passed 👍 Let me know if any further changes are needed :-)

jrose-apple added a commit that referenced this pull request Feb 15, 2016
…fix-to-dot-pep8

[Python] Update list of Python files without .py suffix in .pep8 file.
@jrose-apple jrose-apple merged commit d6ab309 into swiftlang:master Feb 15, 2016
@jrose-apple
Copy link
Contributor

Thanks for sticking this one out. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants