aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-04-05 13:29:05 -0500
committerGitHub <noreply@github.com>2025-04-05 13:29:05 -0500
commitdb808c574da6bfedfcfaf7d1df3f767862f81603 (patch)
tree2e709cb3bcbeee523f3db0302f25c90156f82d7a
parent848223707854b4fd71de8a8fd27651e59bc0d7af (diff)
downloadcleberg.net-db808c574da6bfedfcfaf7d1df3f767862f81603.tar.gz
cleberg.net-db808c574da6bfedfcfaf7d1df3f767862f81603.tar.bz2
cleberg.net-db808c574da6bfedfcfaf7d1df3f767862f81603.zip
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>
-rw-r--r--.github/workflows/pylint.yml26
-rw-r--r--.github/workflows/ruff.yml37
-rw-r--r--utils/salary_visualization.py36
3 files changed, 57 insertions, 42 deletions
diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml
deleted file mode 100644
index 1c22aa5..0000000
--- a/.github/workflows/pylint.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: Pylint
-
-on:
- push:
- paths:
- - '**.py'
-
-jobs:
- build:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- python-version: ["3.8", "3.9", "3.10"]
- steps:
- - uses: actions/checkout@v4
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v3
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install pylint pandas plotly
- - name: Analysing the code with pylint
- run: |
- pylint $(git ls-files '*.py')
diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml
new file mode 100644
index 0000000..2cefea1
--- /dev/null
+++ b/.github/workflows/ruff.yml
@@ -0,0 +1,37 @@
+name: Ruff
+
+on:
+ push:
+ paths:
+ - '**.py'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: ["3.x"]
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v5
+ with:
+ python-version: ${{ matrix.python-version }}
+ ref: ${{ github.event.pull_request.head.ref }}
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install pandas plotly
+ - name: Install Ruff
+ uses: astral-sh/ruff-action@v3.2.2
+ - name: Ruff Actions
+ run: |
+ ruff check --fix
+ ruff format
+ - name: Add and Commit
+ uses: EndBug/add-and-commit@v9
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ default_author: github_actions
+ pathspec_error_handling: ignore
diff --git a/utils/salary_visualization.py b/utils/salary_visualization.py
index a34094b..65503fe 100644
--- a/utils/salary_visualization.py
+++ b/utils/salary_visualization.py
@@ -10,10 +10,11 @@ from pandas import read_csv as pd_read_csv
import pandas as pd
import plotly.graph_objs as go
-locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
+locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
# Read the CSV file
-df = pd_read_csv('~/git/cleberg.net/theme/static/salary.csv')
+df = pd_read_csv("~/git/cleberg.net/theme/static/salary.csv")
+
def format_currency(value: float) -> str:
"""
@@ -27,11 +28,13 @@ def format_currency(value: float) -> str:
"""
return f"${value:,.2f}"
+
# Reverse the order of the DataFrame
df = df.iloc[::-1].reset_index(drop=True)
# Calculate the percentage increase
-df['Percentage Increase'] = df['Salary'].pct_change() * 100
+df["Percentage Increase"] = df["Salary"].pct_change() * 100
+
def create_trace(row: pd.Series) -> go.Scatter:
"""
@@ -44,20 +47,21 @@ def create_trace(row: pd.Series) -> go.Scatter:
go.Scatter: The created scatter plot trace.
"""
title_company = f"{row['Title']} ({row['Company']})"
- salary_formatted = format_currency(row['Salary'])
- if pd.notna(row['Percentage Increase']):
+ salary_formatted = format_currency(row["Salary"])
+ if pd.notna(row["Percentage Increase"]):
text = f"{salary_formatted} ({row['Percentage Increase']:.2f}%)"
else:
text = salary_formatted
return go.Scatter(
- x=[row['Start'], row['End']],
- y=[row['Salary'], row['Salary']],
+ x=[row["Start"], row["End"]],
+ y=[row["Salary"], row["Salary"]],
text=[text],
- mode='lines+text',
+ mode="lines+text",
name=title_company,
- textposition='top center'
+ textposition="top center",
)
+
# Initialize the plot
fig = go.Figure()
@@ -70,16 +74,16 @@ fig.update_layout(
title="Salary Data Over Time (annualized)",
xaxis_title="Time",
yaxis_title="Salary",
- font={"family": 'monospace', "size": 16},
+ font={"family": "monospace", "size": 16},
margin={"l": 50, "r": 50, "t": 50, "b": 100},
legend={
- "orientation": 'h',
- "yanchor": 'top',
- "y": -0.3,
- "xanchor": 'center',
- "x": 0.5
+ "orientation": "h",
+ "yanchor": "top",
+ "y": -0.3,
+ "xanchor": "center",
+ "x": 0.5,
},
- height=800
+ height=800,
)
# Display the plot