Skip to content

Commit 5faa99f

Browse files
Merge pull request #1 from Czaki/main
Modernize project structure to use ruff, pre-commit hook and pyproject.toml
2 parents 8d46ba5 + 4574721 commit 5faa99f

9 files changed

+284
-14
lines changed

.github/workflows/pre-commit.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Pre-commit Check
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
pre-commit:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.10'
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install pre-commit
28+
29+
- name: Run pre-commit
30+
run: pre-commit run --all-files

.pre-commit-config.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.6.4
4+
hooks:
5+
- id: ruff-format
6+
exclude: examples
7+
- id: ruff
8+
- repo: https://github.com/python-jsonschema/check-jsonschema
9+
rev: 0.29.2
10+
hooks:
11+
- id: check-github-workflows
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v4.6.0
14+
# .py files are skipped cause already checked by other hooks
15+
hooks:
16+
- id: check-yaml
17+
- id: check-toml
18+
- id: check-merge-conflict
19+
exclude: .*\.py
20+
- id: end-of-file-fixer
21+
exclude: .*\.py
22+
- id: trailing-whitespace
23+
# trailing whitespace has meaning in markdown https://www.markdownguide.org/hacks/#indent-tab
24+
exclude: .*\.py|.*\.md
25+
- id: mixed-line-ending
26+
exclude: .*\.py

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ pip install -r ./requirements.txt
66
# Running
77
```bash
88
./entrypoint
9-
```
9+
```

entrypoint.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/env bash
2+
13
set -x
24
set -e
35

@@ -7,4 +9,4 @@ then
79
else
810
echo "No CLI command provided, running Dash server"
911
python3 -m hackyeah2024.main server
10-
fi
12+
fi

hackyeah2024/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
@click.group()
77
def main():
8-
print("Running main CLI")
8+
print('Running main CLI')
99

1010

1111
@main.command()
1212
def dummy():
13-
print("Running a dummy script")
13+
print('Running a dummy script')
1414

1515

1616
@main.command()
1717
def server():
18-
print("Running server")
18+
print('Running server')
1919
run_server()
2020

2121

22-
if __name__ == "__main__":
22+
if __name__ == '__main__':
2323
main()

hackyeah2024/server.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import dash_leaflet as dl
2-
from dash import Dash, html
2+
from dash import Dash
33

44

55
def run_server():
@@ -15,12 +15,11 @@ def run_server():
1515
# style={'width': '100%', 'height': '50vh', 'margin': "auto", "display": "block"}, id="map"),
1616
# ])
1717

18-
1918
app = Dash()
2019
app.layout = dl.Map(dl.TileLayer(), center=[56, 10], zoom=6, style={'height': '50vh'})
2120

2221
app.run_server()
2322

2423

25-
if __name__ == "__main__":
24+
if __name__ == '__main__':
2625
run_server()

pyproject.toml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
[project]
2+
name = "hackyeah2024"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
dependencies = [
8+
"dash",
9+
"dash_leaflet",
10+
"taxicab",
11+
]
12+
13+
14+
[tool.ruff]
15+
line-length = 120
16+
exclude = [
17+
".bzr",
18+
".direnv",
19+
".eggs",
20+
".git",
21+
".mypy_cache",
22+
".pants.d",
23+
".ruff_cache",
24+
".svn",
25+
".tox",
26+
".venv",
27+
"__pypackages__",
28+
"_build",
29+
"buck-out",
30+
"build",
31+
"dist",
32+
"node_modules",
33+
"venv",
34+
"*vendored*",
35+
"*_vendor*",
36+
]
37+
38+
fix = true
39+
40+
[tool.ruff.format]
41+
quote-style = "single"
42+
43+
[tool.ruff.lint]
44+
select = [
45+
"E", "F", "W", #flake8
46+
"UP", # pyupgrade
47+
"I", # isort
48+
"YTT", #flake8-2020
49+
"TCH", # flake8-type-checing
50+
"BLE", # flake8-blind-exception
51+
"B", # flake8-bugbear
52+
"A", # flake8-builtins
53+
"C4", # flake8-comprehensions
54+
"ISC", # flake8-implicit-str-concat
55+
"G", # flake8-logging-format
56+
"PIE", # flake8-pie
57+
"COM", # flake8-commas
58+
"SIM", # flake8-simplify
59+
"INP", # flake8-no-pep420
60+
"PYI", # flake8-pyi
61+
"Q", # flake8-quotes
62+
"RSE", # flake8-raise
63+
"RET", # flake8-return
64+
"TID", # flake8-tidy-imports # replace absolutify import
65+
"TRY", # tryceratops
66+
"ICN", # flake8-import-conventions
67+
"RUF", # ruff specyfic rules
68+
"NPY201", # checks compatibility with numpy version 2.0
69+
"ASYNC", # flake8-async
70+
"EXE", # flake8-executable
71+
"FA", # flake8-future-annotations
72+
"LOG", # flake8-logging
73+
"SLOT", # flake8-slots
74+
"PT", # flake8-pytest-style
75+
"T20", # flake8-print
76+
]
77+
ignore = [
78+
"E501", "TCH001", "TCH002", "TCH003",
79+
"A003", # flake8-builtins - we have class attributes violating these rule
80+
"COM812", # flake8-commas - we don't like adding comma on single line of arguments
81+
"COM819", # conflicts with ruff-format
82+
"SIM117", # flake8-simplify - we some of merged with statements are not looking great with black, reanble after drop python 3.9
83+
"RET504", # not fixed yet https://github.com/charliermarsh/ruff/issues/2950
84+
"TRY003", # require implement multiple exception class
85+
"RUF005", # problem with numpy compatybility, see https://github.com/charliermarsh/ruff/issues/2142#issuecomment-1451038741
86+
"B028", # need to be fixed
87+
"PYI015", # it produces bad looking files (@jni opinion)
88+
"W191", "Q000", "Q001", "Q002", "Q003", "ISC001", # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
89+
"T201", # allow print
90+
]

requirements.txt

+128-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,128 @@
1-
dash
2-
dash_leaflet
3-
pep8
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile pyproject.toml -o requirements.txt
3+
blinker==1.8.2
4+
# via flask
5+
certifi==2024.8.30
6+
# via
7+
# pyogrio
8+
# pyproj
9+
# requests
10+
charset-normalizer==3.3.2
11+
# via requests
12+
click==8.1.7
13+
# via flask
14+
contourpy==1.3.0
15+
# via matplotlib
16+
cycler==0.12.1
17+
# via matplotlib
18+
dash==2.18.1
19+
# via
20+
# hackyeah2024 (pyproject.toml)
21+
# dash-leaflet
22+
dash-core-components==2.0.0
23+
# via dash
24+
dash-html-components==2.0.0
25+
# via dash
26+
dash-leaflet==1.0.15
27+
# via hackyeah2024 (pyproject.toml)
28+
dash-table==5.0.0
29+
# via dash
30+
flask==3.0.3
31+
# via dash
32+
fonttools==4.54.1
33+
# via matplotlib
34+
geopandas==1.0.1
35+
# via osmnx
36+
idna==3.10
37+
# via requests
38+
importlib-metadata==8.5.0
39+
# via dash
40+
itsdangerous==2.2.0
41+
# via flask
42+
jinja2==3.1.4
43+
# via flask
44+
kiwisolver==1.4.7
45+
# via matplotlib
46+
markupsafe==2.1.5
47+
# via
48+
# jinja2
49+
# werkzeug
50+
matplotlib==3.9.2
51+
# via taxicab
52+
nest-asyncio==1.6.0
53+
# via dash
54+
networkx==3.3
55+
# via
56+
# osmnx
57+
# taxicab
58+
numpy==2.1.1
59+
# via
60+
# contourpy
61+
# geopandas
62+
# matplotlib
63+
# osmnx
64+
# pandas
65+
# pyogrio
66+
# shapely
67+
# taxicab
68+
osmnx==1.9.3
69+
# via taxicab
70+
packaging==24.1
71+
# via
72+
# geopandas
73+
# matplotlib
74+
# plotly
75+
# pyogrio
76+
pandas==2.2.3
77+
# via
78+
# geopandas
79+
# osmnx
80+
pillow==10.4.0
81+
# via matplotlib
82+
plotly==5.24.1
83+
# via dash
84+
pyogrio==0.9.0
85+
# via geopandas
86+
pyparsing==3.1.4
87+
# via matplotlib
88+
pyproj==3.6.1
89+
# via geopandas
90+
python-dateutil==2.9.0.post0
91+
# via
92+
# matplotlib
93+
# pandas
94+
pytz==2024.2
95+
# via pandas
96+
requests==2.32.3
97+
# via
98+
# dash
99+
# osmnx
100+
retrying==1.3.4
101+
# via dash
102+
setuptools==75.1.0
103+
# via dash
104+
shapely==2.0.6
105+
# via
106+
# geopandas
107+
# osmnx
108+
# taxicab
109+
six==1.16.0
110+
# via
111+
# python-dateutil
112+
# retrying
113+
taxicab==0.0.3
114+
# via hackyeah2024 (pyproject.toml)
115+
tenacity==9.0.0
116+
# via plotly
117+
typing-extensions==4.12.2
118+
# via dash
119+
tzdata==2024.2
120+
# via pandas
121+
urllib3==2.2.3
122+
# via requests
123+
werkzeug==3.0.4
124+
# via
125+
# dash
126+
# flask
127+
zipp==3.20.2
128+
# via importlib-metadata

setup.cfg

-2
This file was deleted.

0 commit comments

Comments
 (0)