Skip to content

Commit c7bdb2f

Browse files
authored
Merge pull request #328 from arjunsuresh/patch-7
Removed a misleading warning in server.py and added a github action for automatic black formatting
2 parents d1deb7b + a0dcb24 commit c7bdb2f

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

.github/workflows/format.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Automatic code formatting
2+
name: "Code formatting"
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
8+
env:
9+
python_version: "3.9"
10+
11+
jobs:
12+
format-code:
13+
runs-on: ubuntu-latest
14+
if: ${{ github.repository_owner != 'mlcommons' }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
ssh-key: ${{ secrets.DEPLOY_KEY }}
20+
- name: Set up Python ${{ env.python_version }}
21+
uses: actions/setup-python@v3
22+
with:
23+
python-version: ${{ env.python_version }}
24+
25+
- name: Format modified python files
26+
run: |
27+
python3 -m pip install black
28+
for FILE in $(git diff --name-only ${{ github.event.before }} | grep -E '.*\.py$')
29+
do
30+
black $FILE
31+
git add $FILE
32+
done
33+
34+
35+
- name: Commit and Push
36+
run: |
37+
HAS_CHANGES=$(git diff --staged --name-only)
38+
if [ -n "$HAS_CHANGES" ]; then
39+
git config --global user.name mlcommons-bot
40+
git config --global user.email "[email protected]"
41+
# Commit changes
42+
git commit -m '[Automated Commit] Format Codebase'
43+
git push
44+
45+
# Push changes to a new branch
46+
#BRANCH_NAME="auto/code-format"
47+
#git branch $BRANCH_NAME
48+
#git push origin $BRANCH_NAME --force
49+
50+
# Create a pull request to the "code-format" branch
51+
#gh pr create --base code-format --head $BRANCH_NAME --title "[Automated PR] Format Codebase" --body "This pull request contains automated code formatting changes."
52+
fi
53+
# env:
54+
# GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}

ptd_client_server/lib/server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,12 @@ def get(
443443
f"{', '.join(unused_options)}"
444444
)
445445

446-
unused_sections = set(conf.sections()) - {"server", "ptd"}
446+
unused_sections = (
447+
set(conf.sections())
448+
- {"server", "ptd"}
449+
- set([i for i in conf.sections() if i.startswith("analyzer")])
450+
)
451+
447452
if len(unused_sections) != 0:
448453
logging.warning(
449454
f"{filename}: ignoring unknown sections: {', '.join(unused_sections)}"

0 commit comments

Comments
 (0)