Skip to content

Commit

Permalink
🔧 upgrade tooling, use pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
krmax44 committed Sep 16, 2024
1 parent 1f97274 commit 04cd50d
Show file tree
Hide file tree
Showing 12 changed files with 382 additions and 1,265 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

36 changes: 0 additions & 36 deletions .eslintrc.json

This file was deleted.

54 changes: 20 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,43 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Cache pip
uses: actions/cache@v1
with:
key: v0-${{ runner.os }}-pip-lint-${{ hashFiles('setup.py') }}
path: ~/.cache/pip
restore-keys: |
v0-${{ runner.os }}-pip-lint-
v0-${{ runner.os }}-pip-
- name: Install system-level dependencies
run: sudo apt-get update && sudo apt-get install python3-dev libmagic-dev libmagickwand-dev poppler-utils libpoppler-cpp-dev
- name: Install dependencies
run: |
pip install -e ".[test]"
yarn install
- name: Run flake8
run: flake8 src tests test_project --statistics
- name: Run black
run: black --check src tests test_project
- name: Run isort
run: isort --check src tests test_project
- name: Run eslint
run: yarn lint
- uses: actions/checkout@v4
- uses: pre-commit/[email protected]

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install system-level dependencies
run: sudo apt-get update && sudo apt-get install python3-dev libmagic-dev libmagickwand-dev poppler-utils libpoppler-cpp-dev
- name: uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('requirements-dev.txt') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('requirements-dev.txt') }}
uv-${{ runner.os }}
- name: Install dependencies
run: |
pip install -e ".[test]"
playwright install --with-deps chromium
python -m pip install uv
uv pip install ".[test]"
yarn install
- name: Build frontend
run: yarn run build
- name: Run tests
run: coverage run --branch -m pytest -m "not slow"
- name: Show coverage report
run: coverage report
- name: Minimize uv cache
run: uv cache prune --ci
51 changes: 17 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/psf/black
rev: "22.3.0" # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
- repo: https://github.com/pycqa/flake8
rev: "3.9.2" # pick a git hash / tag to point to
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.35.2
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==21.4.3]
exclude: ^.*/migrations/.*$
- id: djlint-reformat-django
- id: djlint-django

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.21.0
rev: v9.9.1
hooks:
- id: eslint
files: \.(js|ts|vue)?$
files: \.(js|vue)?$
types: [file]
args: [--no-warn-ignored]
additional_dependencies:
- [email protected]
- eslint-config-standard-with-typescript
- eslint-plugin-html
- eslint-plugin-import
- eslint-plugin-n
- eslint-plugin-promise
- eslint-plugin-vue
- eslint
- prettier
- eslint-plugin-prettier
- eslint-config-standard
- repo: local
hooks:
- id: make-messages
name: Update translation files
entry: make messagesde
language: system
pass_filenames: false

exclude: ^.*/migrations/.*$
- eslint-config-prettier
- eslint-plugin-vue
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include README.md LICENSE.txt
include README.md LICENSE.txt package.json
recursive-include src/filingcabinet/templates *
recursive-include src/filingcabinet/static *
recursive-include src/filingcabinet/locale *.po
recursive-include frontend *
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import prettier from 'eslint-config-prettier'
import pluginVue from 'eslint-plugin-vue'
import js from '@eslint/js'

export default [
{
ignores: ['node_modules', '**/static', '**/build']
},
js.configs.recommended,
...pluginVue.configs['flat/strongly-recommended'],
prettier
]
15 changes: 0 additions & 15 deletions jsconfig.json

This file was deleted.

30 changes: 11 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"dev": "vite",
"build": "vite build"
},
"files": [
"frontend/*"
],
"dependencies": {
"@popperjs/core": "^2.11.6",
"bootstrap": "^5.3.0",
Expand All @@ -21,26 +24,15 @@
"vue": "^3.3.4",
"vue-virtual-scroller": "^2.0.0-alpha.1"
},
"files": [
"frontend/*"
],
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.2.0",
"@typescript-eslint/parser": "^6.2.0",
"@vitejs/plugin-vue": "^4.2.3",
"eslint": "^8.45.0",
"eslint-config-prettier": "8.9.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-prettier": "4",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-vue": "^9.3.0",
"prettier": "^2.4.0",
"prettier-config-standard": "^5.0.0",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.27.0",
"prettier": "^3.3.3",
"sass": "^1.54.4",
"typescript": "^5.1.6",
"typescript-eslint": "^8.3.0",
"vite": "^4.4.7"
}
}
},
"prettier": "prettier-config-standard"
}
104 changes: 61 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
name = "django-filingcabinet"
version = "0.0.1"
dependencies = [
"Django",
"wand",
"pypdf",
"PyCryptodome",
"pikepdf",
"Pillow",
"django-filter",
"django-json-widget",
"jsonschema",
"django-taggit>=2",
"django-treebeard",
"djangorestframework",
"reportlab",
"celery",
"feedgen",
"zipstream",
"python-poppler",
"Django",
"wand",
"pypdf",
"PyCryptodome",
"pikepdf",
"Pillow",
"django-filter",
"django-json-widget",
"jsonschema",
"django-taggit>=2",
"django-treebeard",
"djangorestframework",
"reportlab",
"celery",
"feedgen",
"zipstream",
"python-poppler",
]
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -29,27 +29,22 @@ tabledetection = ["camelot-py[cv]"]
ocr = ["pytesseract"]
webp = ["webp"]
annotate = [
"fcdocs-annotate @ https://github.com/okfde/fcdocs-annotate/archive/refs/heads/main.zip",
"fcdocs-annotate @ https://github.com/okfde/fcdocs-annotate/archive/refs/heads/main.zip",
]
test = [
"black==22.*",
"coverage[toml]",
"django-coverage-plugin",
"django-stubs",
"djangorestframework-stubs",
"factory_boy",
"flake8-bugbear",
"flake8",
"isort",
"monkeytype",
"mypy-extensions",
"mypy",
"pre-commit",
"pycodestyle",
"pytest-django",
"pytest-factoryboy",
"pytest-playwright",
"pytest",
"coverage[toml]",
"django-coverage-plugin",
"django-stubs",
"djangorestframework-stubs",
"factory_boy",
"monkeytype",
"mypy-extensions",
"mypy",
"pycodestyle",
"pytest-django",
"pytest-factoryboy",
"pytest-playwright",
"pytest",
]

[tool.pytest.ini_options]
Expand All @@ -64,13 +59,36 @@ package-dir = { "" = "src" }
[tool.setuptools.packages.find]
where = ["src"]

[tool.isort]
profile = "black"
src_paths = ["filingcabinet"]
default_section = "THIRDPARTY"
known_first_party = "filingcabinet"
known_django = "django"
sections = "FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
[tool.ruff]
exclude = ["migrations", "build", "node_modules"]

[tool.ruff.lint]
ignore = ["E501", "C901"]
select = ["C", "E", "F", "W", "B", "I001"]

[tool.ruff.lint.pycodestyle]
max-line-length = 88

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.lint.isort]
section-order = [
"future",
"standard-library",
"django",
"third-party",
"first-party",
"local-folder",
]
default-section = "third-party"
known-first-party = ["filingcabinet"]

[tool.ruff.lint.isort.sections]
django = ["django"]

[tool.djlint]
ignore = "T002,T003,H005,H006,H021,H023,H029,H030,H031"

[tool.coverage.run]
branch = true
Expand Down
Loading

0 comments on commit 04cd50d

Please sign in to comment.