Skip to content

Commit e958ab2

Browse files
authored
Update files for formatting and correct pre-commit warnings
2 parents 0a5f2d8 + 5501bef commit e958ab2

12 files changed

Lines changed: 173 additions & 97 deletions

File tree

.github/workflows/add-to-help-project.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ on:
55
types:
66
- labeled
77

8+
permissions: {}
9+
810
jobs:
911
add-help-wanted:
1012
runs-on: ubuntu-latest
13+
environment: help-wanted
14+
permissions:
15+
contents: read
16+
issues: write
1117
steps:
1218
- name: Add issue to project
1319
id: add-to-project
14-
uses: actions/add-to-project@v1.0.2
20+
uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
1521
with:
1622
project-url: https://github.com/orgs/pyOpenSci/projects/3
1723
# This is a organization level token so it can be used across all repos in our org

.github/workflows/deploy.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,26 @@ on:
77
push:
88
branches:
99
- main
10+
11+
permissions: {}
12+
1013
env:
1114
# `BASE_URL` determines the website is served from, including CSS & JS assets
1215
# You may need to change this to `BASE_URL: ''`
1316
BASE_URL: /${{ github.event.repository.name }}
1417

1518
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16-
permissions:
17-
contents: read
18-
pages: write
19-
id-token: write
19+
#permissions:
20+
# contents: read
21+
# pages: write
22+
# id-token: write
23+
2024
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
2125
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
2226
concurrency:
2327
group: 'pages'
2428
cancel-in-progress: false
29+
2530
jobs:
2631
build:
2732
runs-on: ubuntu-latest
@@ -31,30 +36,32 @@ jobs:
3136
id-token: write
3237
steps:
3338
- name: Checkout Repo
34-
uses: actions/checkout@v4
39+
with:
40+
persist-credentials: false
41+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3542
- name: Setup Pages
36-
uses: actions/configure-pages@v5
43+
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
3744
# Download latest version of Python
38-
- uses: actions/setup-python@v5
45+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3946
with:
40-
python-version: '3.11'
47+
python-version: '3.11'
4148
cache: 'pip'
4249
- name: Install Dependencies
43-
run: |
50+
run: |
4451
pip install -r requirements.txt
4552
4653
- name: Setup Quarto
47-
uses: quarto-dev/quarto-actions/setup@v2
54+
uses: quarto-dev/quarto-actions/setup@8a96df13519ee81fd526f2dfca5962811136661b # v2
4855
with:
4956
version: "release"
50-
57+
5158
- name: Render dashboard website
52-
uses: quarto-dev/quarto-actions/render@v2
59+
uses: quarto-dev/quarto-actions/render@8a96df13519ee81fd526f2dfca5962811136661b # v2
5360
env:
5461
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5562

5663
- name: Upload artifact
57-
uses: actions/upload-pages-artifact@v3
64+
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
5865

5966
# Only deploy on pyOpenSci owned repo / when pushed to main branch
6067
deploy:
@@ -70,4 +77,4 @@ jobs:
7077
steps:
7178
- name: Deploy to GitHub Pages
7279
id: deployment
73-
uses: actions/deploy-pages@v4
80+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0

.github/workflows/update-pr-data.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
# Runs at 11pm on December 31st every year
1010
- cron: "0 23 31 12 *"
1111

12+
permissions: {}
13+
1214
env:
1315
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1416

@@ -18,9 +20,11 @@ jobs:
1820
runs-on: ubuntu-latest
1921
steps:
2022
- name: Check out the code
21-
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
23+
with:
24+
persist-credentials: false
25+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2226
- name: Setup Python
23-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
27+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 #v6.2.0
2428
with:
2529
python-version: "3.10"
2630
- name: Upgrade pip
@@ -70,9 +74,11 @@ jobs:
7074
if: github.ref == 'refs/heads/main'
7175
steps:
7276
- name: Check out the code
73-
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
77+
with:
78+
persist-credentials: false
79+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7480
- name: Download metrics
75-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
81+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
7682
with:
7783
name: metrics
7884
path: _data

.github/zizmor.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rules:
2+
secrets-outside-env:
3+
ignore:
4+
- add-to-help-project.yml:23:29
5+
- deploy.yml:76:29
6+
- update-pr-data.yml:99:29

.pre-commit-config.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# pre-commit (https://pre-commit.com/) is a tool that runs source code checks
2+
# such as linting, formatting, and code style.
3+
4+
# CI
5+
# pyosMeta uses pre-commit with the precommit.ci bot to check pull requests.
6+
# Configuration reference doc: https://pre-commit.com/#pre-commit-configyaml---top-level
7+
8+
# Developers
9+
# You may want to install pre-commit to run locally on each minimum_pre_commit_version
10+
# See https://pre-commit.com/#install
11+
# To set up pre-commit hooks: pre-commit install
12+
# To run on all files: pre-commit run --all-files
13+
14+
ci:
15+
autofix_prs: false
16+
autofix_commit_msg: |
17+
'[pre-commit.ci 🤖] Apply code format tools to PR'
18+
autoupdate_schedule: monthly
19+
20+
repos:
21+
# Out of the box hooks for pre-commit https://github.com/pre-commit/pre-commit-hooks
22+
- repo: https://github.com/pre-commit/pre-commit-hooks
23+
rev: v6.0.0
24+
hooks:
25+
# Makes sure files end in a newline and only a newline.
26+
- id: end-of-file-fixer
27+
# Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.
28+
- id: check-case-conflict
29+
# Remove trailing whitespace on code lines
30+
- id: trailing-whitespace
31+
32+
# Spelling hook
33+
- repo: https://github.com/codespell-project/codespell
34+
rev: v2.4.2
35+
hooks:
36+
- id: codespell
37+
exclude_types:
38+
- javascript
39+
- scss
40+
- yaml
41+
additional_dependencies:
42+
- tomli
43+
44+
# Linting and formatting for Python code (see pyproject.toml for config)
45+
- repo: https://github.com/astral-sh/ruff-pre-commit
46+
# Ruff version.
47+
rev: v0.15.10
48+
hooks:
49+
# Run the linter.
50+
- id: ruff
51+
args: [ --fix ]
52+
# Run the formatter.
53+
- id: ruff-format
54+
55+
# Ensure GitHub workflows match the expected schema.
56+
- repo: https://github.com/sirosen/check-jsonschema
57+
rev: 0.37.1
58+
hooks:
59+
- id: check-github-workflows
60+
61+
# Find common security issues in GitHub Actions workflows
62+
- repo: https://github.com/woodruffw/zizmor-pre-commit
63+
rev: v1.24.1
64+
hooks:
65+
- id: zizmor

pyosmetrics_pkg/src/pyosmetrics/plot_theme.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
A small module to store functions used to process data in this
2+
A small module to store functions used to process data in this
33
repo
44
55
"""
@@ -26,7 +26,6 @@ def poppins_theme():
2626
"title": {
2727
"fontSize": 26,
2828
"font": "Poppins",
29-
"anchor": "start",
3029
"color": "black",
3130
"anchor": "middle", # centered
3231
"fontWeight": 400,
@@ -38,7 +37,6 @@ def poppins_theme():
3837
"titleFontSize": 16,
3938
"titleFont": "Poppins",
4039
"labelFont": "Poppins",
41-
"labelFontSize": 14,
4240
},
4341
"axisX": { # Configuration specifically for the x-axis
4442
"labelAngle": 0
@@ -84,9 +82,7 @@ def parse_single_issue(issue) -> dict:
8482
parsed_issue = {}
8583

8684
# Extract labels
87-
parsed_issue["labels"] = [
88-
label["name"] for label in issue.get("labels", [])
89-
]
85+
parsed_issue["labels"] = [label["name"] for label in issue.get("labels", [])]
9086

9187
# Extract header text (title of the issue)
9288
parsed_issue["header_text"] = issue.get("title", "")
@@ -129,9 +125,7 @@ def count_edits_by_quarter(df):
129125
DataFrame containing the number of submissions edited by each editor
130126
by quarter.
131127
"""
132-
n_edits = df.groupby(
133-
by=[df["editor"], df["created_at"].dt.to_period("Q")]
134-
).count()
128+
n_edits = df.groupby(by=[df["editor"], df["created_at"].dt.to_period("Q")]).count()
135129
n_edits.rename(columns=dict(created_at="n_edits"), inplace=True)
136130
return n_edits
137131

scripts/get-editors.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
"""This script updates our editorial team csv file with the most current editors.
22
3-
1. It parses a manually created list of editors found in the csv
4-
file: `_data/editorial_team_domains`. This csv was created by
5-
manually adding editor names to the file with domain areas from our Google sheet.
6-
The (private) google sheet is generated from a google form that collects editor
3+
1. It parses a manually created list of editors found in the csv
4+
file: `_data/editorial_team_domains`. This csv was created by
5+
manually adding editor names to the file with domain areas from our Google sheet.
6+
The (private) google sheet is generated from a google form that collects editor
77
expertise and domains when they apply to be an editor with us.
8-
2. The script, uses the GitHub API to return the list of GitHub usernames from
8+
2. The script, uses the GitHub API to return the list of GitHub usernames from
99
the editorial team on GitHub. (see)
1010
* https://github.com/orgs/pyOpenSci/teams/emeritus-editors/members
1111
* https://github.com/orgs/pyOpenSci/teams/editorial-board/members
12-
When we onboard a new editor, we add them to the editorial-board GitHub team so
12+
When we onboard a new editor, we add them to the editorial-board GitHub team so
1313
they have proper permissions in repositories in our organization. When an editor
14-
wishes to step down, we move them to the emeritus-editors team. However, they
15-
may still be active in reviews so we keep them on the editorial-board team until
14+
wishes to step down, we move them to the emeritus-editors team. However, they
15+
may still be active in reviews so we keep them on the editorial-board team until
1616
they have completed all of their reviews.
1717
1818
The GitHub team data are collected using the GitHub graphQL interface.
1919
20-
3. Finally, this script merges the data parsed from the team with the .csv file.
20+
3. Finally, this script merges the data parsed from the team with the .csv file.
2121
22-
This script creates two .csv files. The _data/editorial_team_domains.csv contains
23-
all currently "activate" editors. _data/emeritus_editor_domains.csv contains
24-
editors that are either fully offboarded of intend to offboard after theyr currently
25-
active reviews.
22+
This script creates two .csv files. The _data/editorial_team_domains.csv contains
23+
all currently "activate" editors. _data/emeritus_editor_domains.csv contains
24+
editors that are either fully offboarded or intend to offboard after they
25+
finish their currently active reviews.
2626
2727
TODO:
28-
* it would be good to find a more automated way to get the domain data from our
29-
Google Sheet. one way to do this would be to create a new spreadsheet that
30-
pulls from our editor signup but only contains gh username and then the domain
31-
areas.
28+
* it would be good to find a more automated way to get the domain data from our
29+
Google Sheet. one way to do this would be to create a new spreadsheet that
30+
pulls from our editor signup but only contains gh username and then the domain
31+
areas.
3232
3333
"""
3434

@@ -47,9 +47,9 @@
4747

4848

4949
def get_team_members(team_name: str = "editorial-board"):
50-
"""A function that hits the GH graphQL api and pulls down members
51-
from our editorial team. This list should be the most current list of
52-
pyOpenSci editors. """
50+
"""A function that hits the GH graphQL api and pulls down members
51+
from our editorial team. This list should be the most current list of
52+
pyOpenSci editors."""
5353

5454
query = """
5555
query ($slug: String!){
@@ -71,9 +71,7 @@ def get_team_members(team_name: str = "editorial-board"):
7171
}
7272

7373
response = requests.post(
74-
GITHUB_API_URL,
75-
json={"query": query, "variables": variables},
76-
headers=headers
74+
GITHUB_API_URL, json={"query": query, "variables": variables}, headers=headers
7775
)
7876

7977
if response.status_code == 200:
@@ -91,10 +89,9 @@ def filter_members(members, exclude):
9189

9290

9391
if __name__ == "__main__":
94-
9592
# Pull down the list of GitHub usernames from our teams
9693
editors = get_team_members("editorial-board")
97-
emeritus = get_team_members("emeritus-editors")
94+
emeritus = get_team_members("emeritus-editors")
9895

9996
# Cleanup usernames
10097
editors = sorted({(u or "").strip().lower() for u in editors})
@@ -103,11 +100,19 @@ def filter_members(members, exclude):
103100
# Open the CSV that contains domain info for editors
104101
data_dir = Path("_data")
105102
editor_domains = pd.read_csv(data_dir / "editorial_team_domains.csv")
106-
editor_domains["gh_username"] = (editor_domains["gh_username"].astype(str))
103+
editor_domains["gh_username"] = editor_domains["gh_username"].astype(str)
107104

108105
# Build DataFrames of current editors and emeritus from the live team lists
109-
editors_df = pd.DataFrame(editors, columns=["gh_username"]) if editors else pd.DataFrame(columns=["gh_username"])
110-
emeritus_df = pd.DataFrame(emeritus, columns=["gh_username"]) if emeritus else pd.DataFrame(columns=["gh_username"])
106+
editors_df = (
107+
pd.DataFrame(editors, columns=["gh_username"])
108+
if editors
109+
else pd.DataFrame(columns=["gh_username"])
110+
)
111+
emeritus_df = (
112+
pd.DataFrame(emeritus, columns=["gh_username"])
113+
if emeritus
114+
else pd.DataFrame(columns=["gh_username"])
115+
)
111116

112117
# Merge with domain info (left join to keep the team list as the source of truth)
113118
all_editors = editors_df.merge(editor_domains, on="gh_username", how="left")

0 commit comments

Comments
 (0)