lgeiger / black-action Goto Github PK
View Code? Open in Web Editor NEWA GitHub action that runs black code formatter for Python
License: MIT License
A GitHub action that runs black code formatter for Python
License: MIT License
I'm currently struggling to get this set up over in https://github.com/mlissner/black-tests. It seems like it should be so simple, but getting the github action figured out is really hard, apparently. I'm sort of just batting around in the dark. Making progress, but with much frustration.
Would it be possible to provide an example repository using this action? Or to have it run on this repository?
Thanks for the great tool. I hope I can get it to work!
Hello,
Starting last week, all of our black
GitHub actions started failing during setup, for example: https://github.com/Zulko/moviepy/pull/1334/checks?check_run_id=1220896230
I wonder if the default Python version install in the docker file has changed - FROM python:3
- maybe it went to Python 3.9? (python/typed_ast#146 might be relevant).
I just learned that #3 fixes the issue that I've been having trying to get things working today. I got this action from the Github marketplace, and it gave me a copy/paste dialog that used v1.0.1 instead of master. Switching to master fixes things.
Would it make sense to do a release since #3 is fixed? Otherwise the default instructions from the marketplace fail.
Use case: I make a modification of a repo's (that I do not own) code and send in a PR. Black-action runs on that PR and instead of failing the run, it replaces the code in my PR with Black formatted code. This would make Black formatting automatic instead of forcing committers to do it manually each time that tests fail.
action "Lint" {
uses = "lgeiger/black-action@master"
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
args = ". --check"
}
https://developer.github.com/actions/managing-workflows/storing-secrets/#github-token-secret
git diff master -U0 | black --diff # would provide a diff for each file
For each Python file that had a diff, we could commit the black changes back into the PR.
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.
The latest release of black seems to break the image build.
Failed to build regex
Installing collected packages: regex, typed-ast, pathspec, appdirs, toml, click, attrs, black
Running setup.py install for regex: started
Running setup.py install for regex: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o7zo_sju/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o7zo_sju/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vvj9t9bd/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-o7zo_sju/regex/
Complete output (22 lines):
BASE_DIR is /tmp/pip-install-o7zo_sju/regex
/usr/local/lib/python3.8/site-packages/setuptools/dist.py:472: UserWarning: Normalizing '2019.08.19' to '2019.8.19'
warnings.warn(
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/regex
copying regex_3/regex/__init__.py -> build/lib.linux-x86_64-3.8/regex
copying regex_3/regex/regex.py -> build/lib.linux-x86_64-3.8/regex
copying regex_3/regex/_regex_core.py -> build/lib.linux-x86_64-3.8/regex
creating build/lib.linux-x86_64-3.8/regex/test
copying regex_3/regex/test/__init__.py -> build/lib.linux-x86_64-3.8/regex/test
copying regex_3/regex/test/test_regex.py -> build/lib.linux-x86_64-3.8/regex/test
running build_ext
building 'regex._regex' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/regex_3
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.8 -c regex_3/_regex.c -o build/temp.linux-x86_64-3.8/regex_3/_regex.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o7zo_sju/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o7zo_sju/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vvj9t9bd/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
The command '/bin/sh -c pip install black' returned a non-zero code: 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.