Skip to content

Commit

Permalink
chore: use poetry and add ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare committed Apr 8, 2024
1 parent 0b8e090 commit 2ec7d93
Show file tree
Hide file tree
Showing 20 changed files with 885 additions and 281 deletions.
35 changes: 8 additions & 27 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
name: Python Testing
name: Lint and Test

on:
pull_request:
push:
branches:
- main
- master

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.8, 3.11]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install -r requirements-dev.txt
pytest
test-python-poetry:
uses: radiorabe/actions/.github/workflows/[email protected]
pre-commit:
uses: radiorabe/actions/.github/workflows/[email protected]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__pycache__
.venv/
.coverage
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.3.2'
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: ^src/api/client.js$
- id: end-of-file-fixer
exclude: ^src/api/client.js$
- id: check-symlinks
- id: check-merge-conflict
- id: check-case-conflict
- id: detect-aws-credentials
args:
- --allow-missing-credentials
- id: detect-private-key
308 changes: 308 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

Empty file added py.typed
Empty file.
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[tool.poetry]
name = "kanboard_tasks_from_email"
version = "0.0.0" # 0.0.0 placeholder is replaced on release
description = "Script to create kanboard tasks from email"
repository = "https://github.com/radiorabe/kanboard-tasks-from-email"
authors = ["IT Reaktion <[email protected]>"]
license = "AGPL-3"
readme = "README.md"
packages = [{include = "src/tasks_from_email.py" }]

[tool.poetry.scripts]
kanboard-tasks-from-email = 'tasks_from_email:main'

[tool.poetry.dependencies]
python = "^3.11"
kanboard = "^1.1.5"
ConfigArgParse = "^1.7"

[tool.poetry.group.dev.dependencies]
pytest = "^8.1.1"
pytest-cov = "^5.0.0"
pytest-freezegun = "^0.4.2"
pytest-mock = "^3.14.0"
pytest-random-order = "^1.1.1"
pytest-ruff = "^0.3.1"
ruff = "^0.3.5"

[tool.pytest.ini_options]
minversion = "8.1"
addopts = "-ra -q --random-order --doctest-glob='*.md' --doctest-modules --cov=src --cov-fail-under=100 --cov-report=html --ruff --mypy --ignore docs/"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 0 additions & 4 deletions requirements-dev.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

78 changes: 78 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# [ruff](https://docs.astral.sh/ruff/) config
#
# templated with https://github.com/radiorabe/backstage-software-templates

[lint]
select = [
"F", # pyflakes
"E", # pycodestyle errors
"I", # isort
"C90", # mccabe
"N", # pep8-naming
"D", # pydocstyle
"UP", # pyupgrade
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"S", # flake8-bandit
"BLE", # flake8-blind-exception
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"EM", # flake8-errmsg
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
"TD", # flake8-todos
"ERA", # eradicate
"PGH", # pygrep-hooks
"PL", # Pylint
"TRY", # tryceratops
"PERF", # Perflint
"RUF", # ruff specific rules
]
ignore = [
"D203", # we prefer blank-line-before-class (D211) for black compat
"D213", # we prefer multi-line-summary-first-line (D212)
"COM812", # ignore due to conflict with formatter
"ISC001", # ignore due to conflict with formatter
]

[lint.per-file-ignores]
"tests/**/*.py" = [
"D", # pydocstyle is optional for tests
"ANN", # flake8-annotations are optional for tests
"S101", # assert is allow in tests
"S105", # tests may have hardcoded secrets
"S106", # tests may have hardcoded passwords
"S108", # /tmp is allowed in tests since it's expected to be mocked
"DTZ00", # tests often run in UTC
"INP001", # tests do not need a dunder init
]
"**/__init__.py" = [
"D104", # dunder init does not need a docstring because it might be empty
]
"docs/gen_ref_pages.py" = [
"INP001", # mkdocs does not need a dunder init
]
Empty file added src/__init__.py
Empty file.
Loading

0 comments on commit 2ec7d93

Please sign in to comment.