Get rid of the "Skipped X files" messages from isort output.

Review Request #4301 — Created Oct. 12, 2016 and submitted

benjyw
pants
pants-reviews
jsirois, wisechengyi
isort skips __init__.py by default, leading to these confusing messages:
The casual reader will wonder what got skipped, and why, and whether it's OK.

This change to our .isort.cfg files ensures that isort doesn't skip
__init__.py files.  All ours are empty anyway, so isort will do nothing
with them, but this gets rid of those distracting messages.

CI passed: https://travis-ci.org/pantsbuild/pants/builds/167197899

JS
  1. Ship It!
  2. 
      
WI
  1. Messages are muted now, but it does not try to sort __init__.py either. Is that intended?

    $ git diff
    diff --git a/examples/src/python/example/hello/__init__.py b/examples/src/python/example/hello/__init__.py
    index e69de29..27c364e 100644
    --- a/examples/src/python/example/hello/__init__.py
    +++ b/examples/src/python/example/hello/__init__.py
    @@ -0,0 +1,4 @@
    +import pants
    +import os
    +import abc
    +import __future__
    $ ./pants fmt.isort examples/src/python/example/:: -- --check
    
    15:36:01 00:00 [main]
                   (To run a reporting server: ./pants server)
    15:36:01 00:00   [setup]
    15:36:01 00:00     [parse]
                   Executing tasks in goals: fmt
    15:36:01 00:00   [fmt]
    15:36:01 00:00     [isort]
    15:36:02 00:01   [complete]
                   SUCCESS
    
    1. The isort is really intended for pants production code, and we restrict that to use either empty __init__.py or else a namespace package declaration - so sorts are never required.
      As you point out, example code will slip through the cracks, but I think that is probably OK

    2. I think the only reason that specific `__init__.py` file isn't checked is that it doesn't belong to any target.
    3. I'll point out that your example was confusing to me, but I let it ride.  Checking back on our checks, your example is not allowed by another check (so isort is moot): https://github.com/pantsbuild/pants/blob/master/build-support/bin/check_packages.sh
    4. __init__.py is included. but yes, only empty or namespace __init__.py is allowed by check_packages.sh

      Bofore the change:

      $ ./pants fmt.isort examples/tests/python/example_test/hello/:: -ldebug
      ...
      17:06:05 00:00 [main]
                     (To run a reporting server: ./pants server)
      17:06:05 00:00   [setup]
      17:06:05 00:00     [parse]
                     Executing tasks in goals: fmt
      17:06:05 00:00   [fmt]
      17:06:05 00:00     [isort]DEBUG] Selected isort.pex binary bootstrapped to: /Users/yic/.cache/pants/scripts/isort/4.2.5/isort.pex
      DEBUG] /Users/yic/.cache/pants/scripts/isort/4.2.5/isort.pex examples/src/python/example/hello/greet/__init__.py examples/src/python/example/hello/greet/greet.py examples/tests/python/example_test/hello/greet/greet.py
      Skipped 1 files
      17:06:05 00:00   [complete]
      

      After

      17:07:21 00:00 [main]
                     (To run a reporting server: ./pants server)
      17:07:21 00:00   [setup]
      17:07:21 00:00     [parse]
                     Executing tasks in goals: fmt
      17:07:21 00:00   [fmt]
      17:07:21 00:00     [isort]DEBUG] Selected isort.pex binary bootstrapped to: /Users/yic/.cache/pants/scripts/isort/4.2.5/isort.pex
      DEBUG] /Users/yic/.cache/pants/scripts/isort/4.2.5/isort.pex examples/src/python/example/hello/greet/__init__.py examples/src/python/example/hello/greet/greet.py examples/tests/python/example_test/hello/greet/greet.py
      
      17:07:21 00:00   [complete]
      
    5. I think Benjy was probably more motivated by the ./build-support/bin/isort.sh output which uses ./pants -q ... which elides all output in your before/after except for Skipped 1 files - in that use case, the difference in output is much more relevant. In your example, agreed - its ~noise (I think this is what you might be trying to suggest anyhow!).

    6. Note that the file you modified is src/python/example/hello/__init__.py, which isn't checked in either case because it's not in any target.

      The file you're seeing in the debug output, that is now being checked, is examples/src/python/example/hello/greet/__init__.py, which hasn't changed.

      If you apply that edit to this latter file, then it will be checked after my change.

  2. 
      
WI
  1. Ship It!
  2. 
      
BE
BE
Review request changed

Status: Closed (submitted)

Change Summary:

3f3abd98747b125d2e502bcec399b1264c7998ee

Loading...