Commit 4907bbc909

4907bbc909a9b0a3e1b34277c99fefb4b2cbe5ae

parent: c094cb2a27

Unsigned

cmc <hello@cleberg.net> · 2025-04-05 18:29 UTC
committer: <noreply@github.com>

test ruff-action (#4)

* test ruff-action

* Commit from GitHub Actions (Ruff)

* reduce to one python version

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

Layout: unified · split

.github/workflows/pylint.yml deleted −26
@@ -1,26 +0,0 @@
1name: Pylint
2
3on:
4 push:
5 paths:
6 - '**.py'
7
8jobs:
9 build:
10 runs-on: ubuntu-latest
11 strategy:
12 matrix:
13 python-version: ["3.8", "3.9", "3.10"]
14 steps:
15 - uses: actions/checkout@v4
16 - name: Set up Python ${{ matrix.python-version }}
17 uses: actions/setup-python@v3
18 with:
19 python-version: ${{ matrix.python-version }}
20 - name: Install dependencies
21 run: |
22 python -m pip install --upgrade pip
23 pip install pylint pandas plotly
24 - name: Analysing the code with pylint
25 run: |
26 pylint $(git ls-files '*.py')
.github/workflows/ruff.yml added +37
@@ -0,0 +1,37 @@
1name: Ruff
2
3on:
4 push:
5 paths:
6 - '**.py'
7
8jobs:
9 build:
10 runs-on: ubuntu-latest
11 strategy:
12 matrix:
13 python-version: ["3.x"]
14 steps:
15 - uses: actions/checkout@v4
16 - name: Set up Python ${{ matrix.python-version }}
17 uses: actions/setup-python@v5
18 with:
19 python-version: ${{ matrix.python-version }}
20 ref: ${{ github.event.pull_request.head.ref }}
21 - name: Install dependencies
22 run: |
23 python -m pip install --upgrade pip
24 pip install pandas plotly
25 - name: Install Ruff
26 uses: astral-sh/ruff-action@v3.2.2
27 - name: Ruff Actions
28 run: |
29 ruff check --fix
30 ruff format
31 - name: Add and Commit
32 uses: EndBug/add-and-commit@v9
33 env:
34 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35 with:
36 default_author: github_actions
37 pathspec_error_handling: ignore
utils/salary_visualization.py +20 −16
@@ -10,10 +10,11 @@ from pandas import read_csv as pd_read_csv
10import pandas as pd 10import pandas as pd
11import plotly.graph_objs as go 11import plotly.graph_objs as go
12 12
13locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') 13locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
14 14
15# Read the CSV file 15# Read the CSV file
16df = pd_read_csv('~/git/cleberg.net/theme/static/salary.csv') 16df = pd_read_csv("~/git/cleberg.net/theme/static/salary.csv")
17
17 18
18def format_currency(value: float) -> str: 19def format_currency(value: float) -> str:
19 """ 20 """
@@ -27,11 +28,13 @@ def format_currency(value: float) -> str:
27 """ 28 """
28 return f"${value:,.2f}" 29 return f"${value:,.2f}"
29 30
31
30# Reverse the order of the DataFrame 32# Reverse the order of the DataFrame
31df = df.iloc[::-1].reset_index(drop=True) 33df = df.iloc[::-1].reset_index(drop=True)
32 34
33# Calculate the percentage increase 35# Calculate the percentage increase
34df['Percentage Increase'] = df['Salary'].pct_change() * 100 36df["Percentage Increase"] = df["Salary"].pct_change() * 100
37
35 38
36def create_trace(row: pd.Series) -> go.Scatter: 39def create_trace(row: pd.Series) -> go.Scatter:
37 """ 40 """
@@ -44,20 +47,21 @@ def create_trace(row: pd.Series) -> go.Scatter:
44 go.Scatter: The created scatter plot trace. 47 go.Scatter: The created scatter plot trace.
45 """ 48 """
46 title_company = f"{row['Title']} ({row['Company']})" 49 title_company = f"{row['Title']} ({row['Company']})"
47 salary_formatted = format_currency(row['Salary']) 50 salary_formatted = format_currency(row["Salary"])
48 if pd.notna(row['Percentage Increase']): 51 if pd.notna(row["Percentage Increase"]):
49 text = f"{salary_formatted} ({row['Percentage Increase']:.2f}%)" 52 text = f"{salary_formatted} ({row['Percentage Increase']:.2f}%)"
50 else: 53 else:
51 text = salary_formatted 54 text = salary_formatted
52 return go.Scatter( 55 return go.Scatter(
53 x=[row['Start'], row['End']], 56 x=[row["Start"], row["End"]],
54 y=[row['Salary'], row['Salary']], 57 y=[row["Salary"], row["Salary"]],
55 text=[text], 58 text=[text],
56 mode='lines+text', 59 mode="lines+text",
57 name=title_company, 60 name=title_company,
58 textposition='top center' 61 textposition="top center",
59 ) 62 )
60 63
64
61# Initialize the plot 65# Initialize the plot
62fig = go.Figure() 66fig = go.Figure()
63 67
@@ -70,16 +74,16 @@ fig.update_layout(
70 title="Salary Data Over Time (annualized)", 74 title="Salary Data Over Time (annualized)",
71 xaxis_title="Time", 75 xaxis_title="Time",
72 yaxis_title="Salary", 76 yaxis_title="Salary",
73 font={"family": 'monospace', "size": 16}, 77 font={"family": "monospace", "size": 16},
74 margin={"l": 50, "r": 50, "t": 50, "b": 100}, 78 margin={"l": 50, "r": 50, "t": 50, "b": 100},
75 legend={ 79 legend={
76 "orientation": 'h', 80 "orientation": "h",
77 "yanchor": 'top', 81 "yanchor": "top",
78 "y": -0.3, 82 "y": -0.3,
79 "xanchor": 'center', 83 "xanchor": "center",
80 "x": 0.5 84 "x": 0.5,
81 }, 85 },
82 height=800 86 height=800,
83) 87)
84 88
85# Display the plot 89# Display the plot