peter-evans / autopep8 Goto Github PK
View Code? Open in Web Editor NEWA GitHub action for autopep8, a tool that automatically formats Python code to conform to the PEP 8 style guide.
License: MIT License
A GitHub action for autopep8, a tool that automatically formats Python code to conform to the PEP 8 style guide.
License: MIT License
We have often got this failure and are unable to debug it:
Our workflow:
The action code is attached below for reference:
name: autopep8
on: pull_request
jobs:
autopep8:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: autopep8
id: autopep8
uses: peter-evans/[email protected]
with:
args: --exit-code --recursive --in-place --aggressive --aggressive .
- name: Commit autopep8 changes
if: steps.autopep8.outputs.exit-code == 2
run: |
git config --global user.name 'Redacted'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.self_lint }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "self: lint fix"
git push
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
I'm using autopep8 in emacs to write my python-code and lately I found some wrong behaviour of one of the auto-format-features:
Given this wrong code (note the not correctly closed brackets):
def doStuff(self, s_database):
return ("ASDF"
@staticmethod
def doOtherStuff(self, param):
doSomething()
The auto-correct will trigger this wrong behaviour, creating another syntax-error:
def doStuff(self, s_database):
return ("ASDF"
@ staticmethod
def doOtherStuff(self, param):
doSomething()
Here's my Elpy-Config:
Emacs.............: 26.3
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: ipython3 7.13.0 (/usr/bin/ipython3)
RPC virtualenv....: rpc-venv (/home/qohelet/.emacs.d/elpy/rpc-venv)
Python...........: python3 3.8.5 (/home/qohelet/.emacs.d/elpy/rpc-venv/bin/python3)
Jedi.............: 0.18.0
Rope.............: 0.18.0
Autopep8.........: 1.5.5 (1.5.6 available)
Yapf.............: 0.30.0 (0.31.0 available)
Black............: 20.8b1
Syntax checker....: flake8 (/home/qohelet/.local/bin/flake8)
https://github.com/Maagan-Michael/invitease/runs/6257049794?check_suite_focus=true
This is the from the logs:
Restore persisted git credentials
/usr/bin/git config --local --name-only --get-regexp http.https://github.com/.extraheader ^AUTHORIZATION:
http.https://github.com/.extraheader
/usr/bin/git config --local --get-regexp http.https://github.com/.extraheader ^AUTHORIZATION:
http.https://github.com/.extraheader AUTHORIZATION: basic ***
/usr/bin/git config --local --unset http.https://github.com/.extraheader ^AUTHORIZATION:
Unset config key 'http.https://github.com/.extraheader'
/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
Persisted git credentials restored
This issue is for "ChatOps" purposes.
If you are interested in how this works, see slash-command-dispatch.
Here's the workflow I've been thinking about introducing to my repositories:
The github-push-action can assist us in doing so.
Would you like me to try and let you know if that workflow works?
Maybe I miss the proper syntax, but this next one wont exclude any subdirectory
uses: peter-evans/autopep8@v1
with:
args: --recursive --diff --aggressive --aggressive --exclude="vendor" .
vendor is a subdirectory containing external thirdParty python sources. Some of them are not pep8 conformant. I don't want to know or fix it.
My Workflow:
name: autopep8
on: pull_request
jobs:
autopep8:
# Check if the PR is not raised by this workflow and is not from a fork
if: startsWith(github.head_ref, 'autopep8-patches') == false && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: autopep8
id: autopep8
uses: peter-evans/autopep8@v1
with:
args: --exit-code --recursive --in-place --aggressive --aggressive .
- name: Set autopep8 branch name
id: vars
run: echo ::set-output name=branch-name::"autopep8-patches/$GITHUB_HEAD_REF"
- name: Create Pull Request
if: steps.autopep8.outputs.exit-code == 2
uses: peter-evans/create-pull-request@v3
with:
commit-message: autopep8 action fixes
title: Fixes by autopep8 action
body: This is an auto-generated PR with fixes by autopep8.
labels: autopep8
branch: ${{ steps.vars.outputs.branch-name }}
- name: Fail if autopep8 made changes
if: steps.autopep8.outputs.exit-code == 2
run: exit 1
Error: When the repository is checked out on a commit instead of a branch, the 'base' input must be supplied.
Would it be possible, to implement a feature to remove print()-Statements?
I use a 'dev'-branch, that includes a lot of print()-Statements, that are only used for debugging.
They are useless to have in the 'master' branch.
Hi ๐
thanks for the great job you did on this action ,
I was trying to commit the formatted files into a PR made from a fork on a private repository (where this feature of running workflows from forks is enabled).
So I used this action
# push the formatting changes to the PR itself
- name: Commit autopep8 changes
if: steps.autopep8.outputs.exit-code == 2
run: |
git config --global user.name 'Peter Evans'
git config --global user.email '[email protected]'
git commit -am "Automated autopep8 fixes"
git push
but it seems that it's trying to push to the base repo not the fork itself.
and I got this error
remote: Repository not found.
fatal: repository 'https://github.com/<org_name>/<repo_name>/' not found
Error: Process completed with exit code 128.
Knowing that there are couple of developers who forked this repo and want to run the formatting action when they open a PR to the base repo ,Is there any way to address my use case please ?
Thanks in advance.
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.