Skip to content

Commit

Permalink
move tool config to pyproject.toml (GSI-544) (#187)
Browse files Browse the repository at this point in the history
Moved config for:
- ruff
- mypy
- pytest
- coverage
  • Loading branch information
KerstenBreuer authored Dec 20, 2023
1 parent 19c6048 commit d27da9d
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 54 deletions.
5 changes: 0 additions & 5 deletions .coveragerc

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/check_pyproject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check if the config schema and the example are up to date.

on: push

jobs:
static-code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- id: common
uses: ghga-de/gh-action-common@v4

- name: Check pyproject.toml
run: |
./scripts/update_pyproject.py --check
12 changes: 0 additions & 12 deletions .mypy.ini

This file was deleted.

19 changes: 19 additions & 0 deletions .pyproject_generation/pyproject_custom.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[project]
# please adapt to package name
name = "my_microservice"
version = "0.1.0"
description = "My-Microservice - a short description"
dependencies = [
"typer >= 0.9.0",
"ghga-service-commons[api] >= 1.2.0",
"ghga-event-schemas >= 1.0.0",
"hexkit[akafka,s3,mongodb] >= 1.1.0"
]

[project.urls]
# please adapt to package name
Repository = "https://github.com/ghga-de/my-microservice"

[project.scripts]
# please adapt to package name
my-microservice = "my_microservice.__main__:run"
61 changes: 52 additions & 9 deletions .ruff.toml → ...roject_generation/pyproject_template.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
[build-system]
requires = ["setuptools>=67.7.2"]
build-backend = "setuptools.build_meta"

[project]
readme = "README.md"
authors = [
{ name = "German Human Genome Phenome Archive (GHGA)", email = "[email protected]" },
]
requires-python = ">=3.9"
license = { text = "Apache 2.0" }
classifiers = [
"Development Status :: 1 - Planning",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Software Development :: Libraries",
"Intended Audience :: Developers",
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.ruff]
exclude = [
".git",
".devcontainer",
"__pycache__",
"build",
"dist",
]

ignore = [
"E", # pycodestyle errors
"W", # pycodestyle warnings - pycodestyle covered by black
Expand All @@ -23,9 +49,7 @@ ignore = [
"D206", # indent-with-spaces (ignored for formatter)
"D300", # triple-single-quotes (ignored for formatter)
]

line-length = 88

select = [
"C90", # McCabe Complexity
"F", # pyflakes codes
Expand All @@ -39,26 +63,45 @@ select = [
"SIM", # flake8-simplify
"D", # pydocstyle
]

fixable = [
"UP", # e.g. List -> list
"I", # sort imports
"D", # pydocstyle
]

src = ["src", "tests", "examples", "scripts"]

target-version = "py39"

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

[per-file-ignores]
[tool.ruff.per-file-ignores]
"scripts/*" = ["PL", "S", "SIM", "D"]
"tests/*" = ["S", "SIM", "PLR", "B011"]
".devcontainer/*" = ["S", "SIM", "D"]
"examples/*" = ["S", "D"]
"__init__.py" = ["D"]

[pydocstyle]
[tool.ruff.pydocstyle]
convention = "pep257"

[tool.mypy]
disable_error_code = "import"
show_error_codes = true
exclude = [
'build/lib/',
]
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true
no_site_packages = false

[tool.pytest.ini_options]
minversion = "7.1"
asyncio_mode = "strict"

[tool.coverage.paths]
source = [
"src",
"/workspace/src",
"**/lib/python*/site-packages",
]
2 changes: 2 additions & 0 deletions .template/mandatory_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ scripts/script_utils/fastapi_app_location.py
.readme_generation/description.md
.readme_generation/design.md

.pyproject_generation/pyproject_custom.toml

lock/requirements-dev.in
lock/requirements-dev.txt
lock/requirements.txt
Expand Down
5 changes: 5 additions & 0 deletions .template/static_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ scripts/update_openapi_docs.py
scripts/update_readme.py
scripts/update_lock.py
scripts/update_hook_revs.py
scripts/update_pyproject.py
scripts/list_outdated_dependencies.py
scripts/README.md

.github/workflows/check_config_docs.yaml
.github/workflows/check_openapi_spec.yaml
.github/workflows/check_readme.yaml
./github/workflows/check_pyproject.yaml
.github/workflows/check_template_files.yaml
.github/workflows/ci_release.yaml
.github/workflows/ci_workflow_dispatch.yaml
Expand All @@ -45,6 +47,9 @@ example_data/README.md
.readme_generation/.readme_template.md
.readme_generation/README.md

.pyproject_generation/pyproject_template.toml
.pyproject_generation/README.md

lock/requirements-dev-template.in
lock/README.md

Expand Down
136 changes: 113 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,133 @@
[build-system]
requires = ["setuptools>=67.7.2"]
requires = [
"setuptools>=67.7.2",
]
build-backend = "setuptools.build_meta"

[project]
# please adapt to package name
name = "my_microservice"
version = "0.1.0"
description = "My-Microservice - a short description"
readme = "README.md"
authors = [
{ name = "German Human Genome Phenome Archive (GHGA)", email = "[email protected]" },
]
requires-python = ">=3.9"
license = { text = "Apache 2.0" }
classifiers = [
"Development Status :: 1 - Planning",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Software Development :: Libraries",
"Intended Audience :: Developers",
]
dependencies = [
"typer >= 0.9.0",
"ghga-service-commons[api] >= 1.2.0",
"ghga-event-schemas >= 1.0.0",
"hexkit[akafka,s3,mongodb] >= 1.1.0"
"hexkit[akafka,s3,mongodb] >= 1.1.0",
]

[project.urls]
# please adapt to package name
Repository = "https://github.com/ghga-de/my-microservice"

[project.scripts]
# please adapt to package name
my-microservice = "my_microservice.__main__:run"

[tool.setuptools.packages.find]
where = ["src"]
where = [
"src",
]

[tool.ruff]
exclude = [
".git",
".devcontainer",
"__pycache__",
"build",
"dist",
]
ignore = [
"E",
"W",
"PLW",
"RUF001",
"RUF010",
"RUF012",
"N818",
"B008",
"PLR2004",
"D205",
"D400",
"D401",
"D107",
"D206",
"D300",
]
line-length = 88
select = [
"C90",
"F",
"I",
"S",
"B",
"N",
"UP",
"PL",
"RUF",
"SIM",
"D",
]
fixable = [
"UP",
"I",
"D",
]
src = [
"src",
"tests",
"examples",
"scripts",
]
target-version = "py39"

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

[tool.ruff.per-file-ignores]
"scripts/*" = [
"PL",
"S",
"SIM",
"D",
]
"tests/*" = [
"S",
"SIM",
"PLR",
"B011",
]
".devcontainer/*" = [
"S",
"SIM",
"D",
]
"examples/*" = [
"S",
"D",
]
"__init__.py" = [
"D",
]

[tool.ruff.pydocstyle]
convention = "pep257"

[tool.mypy]
disable_error_code = "import"
show_error_codes = true
exclude = [
"build/lib/",
]
warn_redundant_casts = true
warn_unused_ignores = true
check_untyped_defs = true
no_site_packages = false

[tool.pytest.ini_options]
minversion = "7.1"
asyncio_mode = "strict"

[tool.coverage.paths]
source = [
"src",
"/workspace/src",
"**/lib/python*/site-packages",
]
5 changes: 0 additions & 5 deletions pytest.ini

This file was deleted.

Loading

0 comments on commit d27da9d

Please sign in to comment.