lgeiger / black-action

A GitHub action that runs black code formatter for Python
MIT License
190 stars 35 forks source link

Seeing "files would be reformatted" false positive #11

Open asaf-kali opened 3 years ago

asaf-kali commented 3 years ago

Hi, Something weird started happening today: the workflow job

  format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Check black formatting
        uses: lgeiger/black-action@master
        with:
          args: '. -l 120 --exclude ".*/node_modules/.*" --check'

is failing over:

would reformat /github/workspace/academic_helper/forms/login_form.py
would reformat /github/workspace/academic_helper/forms/password_reset_form.py
would reformat /github/workspace/academic_helper/forms/signup_form.py
would reformat /github/workspace/academic_helper/logic/schedule.py
would reformat /github/workspace/academic_helper/management/commands/fetch_courses.py
would reformat /github/workspace/academic_helper/management/init_data.py
would reformat /github/workspace/academic_helper/logic/shnaton_parser.py
would reformat /github/workspace/academic_helper/migrations/0002_ratingdummy.py
would reformat /github/workspace/academic_helper/migrations/0001_initial.py
would reformat /github/workspace/academic_helper/migrations/0003_auto_20200527_1531.py
would reformat /github/workspace/academic_helper/migrations/0004_courseclass_courseoccurrence.py
would reformat /github/workspace/academic_helper/migrations/0006_auto_20200531_1534.py
would reformat /github/workspace/academic_helper/migrations/0007_classschedule.py
would reformat /github/workspace/academic_helper/migrations/0008_auto_20200604_0112.py
would reformat /github/workspace/academic_helper/migrations/0005_auto_20200530_2121.py
would reformat /github/workspace/academic_helper/migrations/0009_auto_20200628_0038.py
would reformat /github/workspace/academic_helper/migrations/0011_auto_20200709_1858.py
would reformat /github/workspace/academic_helper/migrations/0012_auto_20200710_1233.py
would reformat /github/workspace/academic_helper/migrations/0013_coursistuser_degree_program.py
would reformat /github/workspace/academic_helper/migrations/0010_auto_20200629_1808.py
would reformat /github/workspace/academic_helper/migrations/0014_auto_20200814_0226.py
would reformat /github/workspace/academic_helper/migrations/0016_auto_20200814_0317.py
would reformat /github/workspace/academic_helper/migrations/0015_auto_20200814_0231.py
would reformat /github/workspace/academic_helper/migrations/0017_auto_20200814_1153.py
would reformat /github/workspace/academic_helper/migrations/0018_coursecomment.py
would reformat /github/workspace/academic_helper/models/course_comment.py
would reformat /github/workspace/academic_helper/models/coursist_user.py
would reformat /github/workspace/academic_helper/tests/test_courses_logic.py
would reformat /github/workspace/academic_helper/urls.py
would reformat /github/workspace/academic_helper/utils/sentry.py
would reformat /github/workspace/academic_helper/views/schedule.py
would reformat /github/workspace/app/settings.py
Oh no! πŸ’₯ πŸ’” πŸ’₯
32 files would be reformatted, 46 files would be left unchanged.

When running black . -l 120 --exclude ".*/node_modules/.*" in the project root dir, I'm getting the expected output:

All done! ✨ 🍰 ✨
78 files left unchanged.
ToddBradley commented 3 years ago

We noticed the same issue yesterday, where I work.

Gowee commented 3 years ago

It seem to be more related to the black project itself?

Gowee commented 3 years ago

The behavior sounds similar to https://github.com/psf/black/issues/1140 where the problem is a mismatch of black versions in CI and local environments. If it is, the suggestion for simple fix is to upgrade the version of the locally installed black.

asaf-kali commented 3 years ago

Sounds like the right way to go. Currently I can't validate the solution, as now I'm experiencing issue #12 too :)

rickstaa commented 3 years ago

@Gowee This issue is indeed fixed when I update the black version to version 20.8b.

rickstaa commented 3 years ago

Maybe we should put a quick note in the README.md stating that the action uses the latest stable release of black. Alternativelly we can also specify a specific version in the Dockerfile, but I think this is not desired as black should be able to evolve.