diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e742c22..83e777f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,6 +16,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install '.[dev]' - name: black Lint uses: psf/black@24.1.1 - name: isort Lint @@ -26,6 +30,10 @@ jobs: uses: py-actions/flake8@v2 with: plugins: "flake8-pyproject" + - name: lint - FawltyDeps + uses: tweag/FawltyDeps-action@v0.2.0 + with: + options: --detailed templates: name: Templates Lint diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index de1187b..d6442f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,3 +19,8 @@ repos: hooks: - id: djlint-reformat - id: djlint + - repo: https://github.com/tweag/FawltyDeps + rev: v0.18.0 + hooks: + - id: check-undeclared + - id: check-unused diff --git a/Dockerfile b/Dockerfile index ca5dbd0..86ef697 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ COPY leaderboards /data/leaderboards COPY alembic.ini /app COPY pyproject.toml /app/ WORKDIR /app -RUN pip3 install . +RUN pip3 install '.[runtime]' ENV LEADERBOARDS_DIR=/data/leaderboards USER freezing EXPOSE 8000 diff --git a/docker-compose.yml b/docker-compose.yml index 83610f6..66fd9f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,7 +49,7 @@ services: REGISTRATION_SITE: ${REGISTRATION_SITE:-https://freezingsaddles.info/} SECRET_KEY: ${SECRET_KEY:-e6c07402-0307-11e8-b087-000000000000} # yamllint disable-line SQLALCHEMY_URL: "mysql+pymysql://${MYSQL_USER:-freezing}:${MYSQL_PASSWORD:-zeer0}@freezing-db-dev/${MYSQL_DATABASE:-freezing}?charset=utf8mb4&binary_prefix=true" # yamllint disable-line - SQLALCHEMY_URL_ROOT: "mysql+pymysql://${MYSQL_ROOT_USER:-freezing}:${MYSQL_ROOT_PASSWORD:-zeer0}@freezing-db-dev/mysql?charset=utf8mb4&binary_prefix=true" # yamllint disable-line + SQLALCHEMY_URL_ROOT: "mysql+pymysql://${MYSQL_ROOT_USER:-root}:${MYSQL_ROOT_PASSWORD:-fr33z3}@freezing-db-dev/mysql?charset=utf8mb4&binary_prefix=true" # yamllint disable-line START_DATE: ${START_DATE:-2018-01-01T00:00:00-05:00} STRAVA_CLIENT_ID: ${STRAVA_CLIENT_ID:-?} STRAVA_CLIENT_SECRET: ${STRAVA_CLIENT_SECRET:-?} diff --git a/freezing/web/static/css/leaflet-gesture-handling.min.css b/freezing/web/static/css/leaflet-gesture-handling.min.css index 7cbdcfc..69b431e 100644 --- a/freezing/web/static/css/leaflet-gesture-handling.min.css +++ b/freezing/web/static/css/leaflet-gesture-handling.min.css @@ -1 +1 @@ -@-webkit-keyframes leaflet-gestures-fadein{0%{opacity:0}100%{opacity:1}}@keyframes leaflet-gestures-fadein{0%{opacity:0}100%{opacity:1}}.leaflet-container:after{-webkit-animation:leaflet-gestures-fadein .8s backwards;animation:leaflet-gestures-fadein .8s backwards;color:#fff;font-family:Roboto,Arial,sans-serif;font-size:22px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:15px;position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.5);z-index:461;pointer-events:none}.leaflet-gesture-handling-scroll-warning:after,.leaflet-gesture-handling-touch-warning:after{-webkit-animation:leaflet-gestures-fadein .8s forwards;animation:leaflet-gestures-fadein .8s forwards}.leaflet-gesture-handling-touch-warning:after{content:attr(data-gesture-handling-touch-content)}.leaflet-gesture-handling-scroll-warning:after{content:attr(data-gesture-handling-scroll-content)} \ No newline at end of file +@-webkit-keyframes leaflet-gestures-fadein{0%{opacity:0}100%{opacity:1}}@keyframes leaflet-gestures-fadein{0%{opacity:0}100%{opacity:1}}.leaflet-container:after{-webkit-animation:leaflet-gestures-fadein .8s backwards;animation:leaflet-gestures-fadein .8s backwards;color:#fff;font-family:Roboto,Arial,sans-serif;font-size:22px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:15px;position:absolute;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.5);z-index:461;pointer-events:none}.leaflet-gesture-handling-scroll-warning:after,.leaflet-gesture-handling-touch-warning:after{-webkit-animation:leaflet-gestures-fadein .8s forwards;animation:leaflet-gestures-fadein .8s forwards}.leaflet-gesture-handling-touch-warning:after{content:attr(data-gesture-handling-touch-content)}.leaflet-gesture-handling-scroll-warning:after{content:attr(data-gesture-handling-scroll-content)} diff --git a/pyproject.toml b/pyproject.toml index 3d8dc4b..da57539 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,15 @@ requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" +# PEP 420 namespace packages need some special treatment, see +# Thanks @jherland for the hints! +# https://realpython.com/python-namespace-package/ +# https://peps.python.org/pep-0420/ +[tool.setuptools.packages.find] +where = ["."] +include = ["freezing"] +namespaces = true + [project] name = "freezing-web" version = "1.6.0" @@ -18,23 +27,20 @@ authors = [ license = {text = "Apache License (2.0)"} dependencies = [ "Flask==3.1.0", - "GeoAlchemy2==0.16.0", "PyMySQL[rsa]==1.1.1", "PyYAML==6.0.2", "SQLAlchemy==1.4.54", # Thanks https://stackoverflow.com/a/77214086/424301 - Flask did not pin Werkzeug dep "Werkzeug==3.1.3", "arrow==1.3.0", - "autoflake==2.3.1", - "beautifulsoup4==4.12.3", "colorlog==6.9.0", + "python-dateutil==2.9.0.post0", "envparse==0.2.0", "freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.10.4.tar.gz", - "gunicorn==23.0.0", "marshmallow==3.23.2", - "marshmallow-enum @ https://github.com/lyft/marshmallow_enum/archive/support-for-marshamallow-3.tar.gz", "python-instagram==1.3.2", "pytz==2024.2", + "simplejson==3.19.3", "stravalib==1.2.0", ] classifiers = [ @@ -50,15 +56,20 @@ classifiers = [ [project.optional-dependencies] dev = [ + "autoflake", "bandit", "black", "djlint", + "fawltydeps", "flake8", "flake8-pyproject", "isort", "pre-commit", "pymarkdownlnt", ] +runtime = [ + "gunicorn==23.0.0", +] [tool.isort] profile = "black" @@ -71,10 +82,6 @@ max_line_length=88 plugins.md013.enabled = false extensions.front-matter.enabled = true -[tool.setuptools] -# Thanks https://stackoverflow.com/a/72547402/424301 -py-modules = ["freezing"] - [project.scripts] freezing-server = "freezing.web.runserver:main" @@ -89,3 +96,20 @@ max-line-length = 88 max-complexity = 39 extend-ignore = "E203" inline-quotes = "double" + +[tool.fawltydeps] +ignore_unused = [ + "PyMySQL", + "autoflake", + "bandit", + "black", + "djlint", + "fawltydeps", + "flake8", + "flake8-pyproject", + "freezing-model", + "gunicorn", + "isort", + "pre-commit", + "pymarkdownlnt", +]