Skip to content

Commit

Permalink
Expand scope of python file format checks.
Browse files Browse the repository at this point in the history
This expands check_header.sh and isort.sh scope out to the examples/ and
testprojects/ directories.

Testing Done:
I ran `./build-support/bin/check_header.sh` and
`./build-support/bin/isort.sh -f` producing the examples/ and
testprojects/ fixes in this RB.

CI went green here:
  https://travis-ci.org/pantsbuild/pants/builds/49789005

Bugs closed: 1052

Reviewed at https://rbcommons.com/s/twitter/r/1729/
  • Loading branch information
jsirois committed Feb 6, 2015
1 parent 7177ef1 commit 58b6b15
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build-support/bin/check_header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from __future__ import (absolute_import, division, generators, nested_scopes, pr
EOF
)

py_files=$(find src tests pants-plugins -name '*.py' -not -name __init__.py)
py_files=$(find src tests pants-plugins examples -name '*.py' -not -name __init__.py)
known_bad_headers=$(cat <<EOF
tests/python/pants_test/tasks/false.py
tests/python/pants_test/tasks/true.py
Expand Down
2 changes: 1 addition & 1 deletion build-support/bin/isort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ function activate_isort() {

activate_isort

isort ${isort_args[@]} --recursive src tests pants-plugins
isort ${isort_args[@]} --recursive src tests pants-plugins examples

9 changes: 9 additions & 0 deletions examples/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See the menu of settings available here:
# https://github.com/timothycrosley/isort/wiki/isort-Settings

[settings]
line_length=100
indent=2
lines_after_imports=2
known_first_party=example
default_section=THIRDPARTY
4 changes: 2 additions & 2 deletions examples/src/python/example/hello/greet/greet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (nested_scopes, generators, division, absolute_import, with_statement,
print_function, unicode_literals)
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

from colors import green

Expand Down
4 changes: 2 additions & 2 deletions examples/src/python/example/hello/main/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (nested_scopes, generators, division, absolute_import, with_statement,
print_function, unicode_literals)
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import sys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import os

from pants.backend.jvm.targets.java_library import JavaLibrary
from pants.backend.jvm.tasks.jar_task import JarTask
from pants.util.dirutil import safe_mkdir


##
## See `Appendix A` in the 'publish' documentation:
##
Expand Down
7 changes: 4 additions & 3 deletions examples/src/python/example/pants_publish_plugin/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (nested_scopes, generators, division, absolute_import, with_statement,
print_function, unicode_literals)
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

from example.pants_publish_plugin.extra_test_jar_example import ExtraTestJarExample
from pants.goal.task_registrar import TaskRegistrar as task

from example.pants_publish_plugin.extra_test_jar_example import ExtraTestJarExample


# Register this custom task on the 'jar' phase. When the RoundEngine reaches this phase, it will
# execute all tasks that have previously registered for this phase.
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/python/example_test/hello/greet/greet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import (nested_scopes, generators, division, absolute_import, with_statement,
print_function, unicode_literals)
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import os
import unittest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

# Illustrate using Thrift-generated code from Python.
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)

import unittest

from com.pants.examples.distance.ttypes import Distance
from com.pants.examples.precipitation.ttypes import Precipitation


# Illustrate using Thrift-generated code from Python.


class UseThriftTest(unittest.TestCase):
def test_make_it_rain(self):
distance = Distance()
Expand Down

0 comments on commit 58b6b15

Please sign in to comment.