Skip to content

Commit 5dbefde

Browse files
committed
convert to proper python project, create CLI tool stub
1 parent 8f64006 commit 5dbefde

8 files changed

Lines changed: 310 additions & 46 deletions

File tree

.pre-commit-config.yaml

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,22 @@ exclude: "^{{ cookiecutter.*" # <-- added
55
repos:
66
# GH Actions
77
- repo: https://github.com/python-jsonschema/check-jsonschema
8-
rev: '0.22.0'
8+
rev: '0.27.2'
99
hooks:
1010
- id: check-github-workflows
1111

12-
# General Python linters and formatters
13-
- repo: https://github.com/pycqa/isort
14-
rev: '5.12.0'
12+
# Code Quality
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.1.6
1515
hooks:
16-
- id: isort
17-
args: ['--profile', 'black']
18-
- repo: https://github.com/ambv/black
19-
rev: '23.1.0'
20-
hooks:
21-
- id: black
22-
- repo: https://github.com/PyCQA/autoflake
23-
rev: v2.1.1
24-
hooks:
25-
- id: autoflake
26-
27-
# Quality
28-
- repo: https://github.com/pycqa/flake8
29-
rev: '6.0.0'
30-
hooks:
31-
- id: flake8
32-
additional_dependencies:
33-
- Flake8-pyproject==1.2.3
34-
- flake8-bugbear==23.3.23
35-
- dlint==0.14.1
36-
- repo: https://github.com/pycqa/pydocstyle
37-
rev: '6.3.0'
38-
hooks:
39-
- id: pydocstyle
40-
additional_dependencies: ["tomli==2.0.1"]
41-
files: "^src/"
16+
- id: ruff
17+
types_or: [ python, pyi, jupyter ]
18+
args: [ --fix ]
19+
- id: ruff-format
20+
types_or: [ python, pyi, jupyter ]
4221

4322
- repo: https://github.com/pre-commit/mirrors-mypy
44-
rev: 'v1.1.1'
23+
rev: 'v1.7.1'
4524
hooks:
4625
- id: mypy
4726
args: [--no-strict-optional, --ignore-missing-imports]
@@ -60,18 +39,18 @@ repos:
6039
hooks:
6140
- id: validate-cff
6241
- repo: https://github.com/fsfe/reuse-tool
63-
rev: 'v1.1.2'
42+
rev: 'v2.1.0'
6443
hooks:
6544
- id: reuse
6645

6746
- repo: https://github.com/Materials-Data-Science-and-Informatics/somesy
68-
rev: 'v0.1.0'
47+
rev: 'v0.2.0'
6948
hooks:
7049
- id: somesy
7150

7251
# Various general + format-specific helpers
7352
- repo: https://github.com/pre-commit/pre-commit-hooks
74-
rev: v4.4.0
53+
rev: v4.5.0
7554
hooks:
7655
- id: check-symlinks
7756
- id: trailing-whitespace

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ Files: .gitignore pyproject.toml poetry.lock .pre-commit-config.yaml .somesy.tom
1111
Copyright: 2023 Forschungszentrum Jülich GmbH - Institute for Materials Data Science and Informatics (IAS9) - Stefan Sandfeld <s.sandfeld@fz-juelich.de>
1212
License: CC0-1.0
1313

14-
Files: tests/* hooks/*
14+
Files: src/* tests/* hooks/*
1515
Copyright: 2023 Forschungszentrum Jülich GmbH - Institute for Materials Data Science and Informatics (IAS9) - Stefan Sandfeld <s.sandfeld@fz-juelich.de>
1616
License: MIT

codemeta.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,34 @@
5757
"runtimePlatform": "Python 3",
5858
"version": "^2.1.1"
5959
},
60+
{
61+
"@type": "SoftwareApplication",
62+
"identifier": "pydantic",
63+
"name": "pydantic",
64+
"runtimePlatform": "Python 3",
65+
"version": "^2.5.2"
66+
},
6067
{
6168
"@type": "SoftwareApplication",
6269
"identifier": "python",
6370
"name": "python",
6471
"runtimePlatform": "Python 3",
6572
"version": "^3.8"
73+
},
74+
{
75+
"@type": "SoftwareApplication",
76+
"identifier": "typer",
77+
"name": "typer",
78+
"runtimePlatform": "Python 3",
79+
"version": "^0.9.0"
6680
}
6781
],
82+
"targetProduct": {
83+
"@type": "CommandLineApplication",
84+
"executableName": "fair-python-cookiecutter",
85+
"name": "fair-python-cookiecutter",
86+
"runtimePlatform": "Python 3"
87+
},
6888
"url": "https://materials-data-science-and-informatics.github.io/fair-python-cookiecutter",
6989
"version": "0.1.0"
7090
}

poetry.lock

Lines changed: 193 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,37 @@ authors = ["Anton Pirogov <a.pirogov@fz-juelich.de>"]
77
maintainers = ["Anton Pirogov <a.pirogov@fz-juelich.de>"]
88
license = "MIT"
99

10-
keywords = ["fair", "metadata", "python", "cookiecutter", "template"]
10+
readme = "README.md"
1111
repository = "https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter"
1212
homepage = "https://materials-data-science-and-informatics.github.io/fair-python-cookiecutter"
1313
documentation = "https://materials-data-science-and-informatics.github.io/fair-python-cookiecutter"
14+
15+
keywords = ["fair", "metadata", "python", "cookiecutter", "template"]
1416
# ---- managed by somesy, see .somesy.toml ----
1517

1618
classifiers = [
1719
"Intended Audience :: Science/Research",
1820
"Intended Audience :: Developers",
1921
]
20-
readme = "README.md"
22+
23+
# the Python packages that will be included in a built distribution:
24+
packages = [{include = "fair_python_cookiecutter", from = "src"}]
25+
26+
# always include basic info for humans and core metadata in the distribution,
27+
# include files related to test and documentation only in sdist:
28+
include = [
29+
"*.md", "LICENSE", "LICENSES", ".reuse/dep5", "CITATION.cff", "codemeta.json",
30+
"mkdocs.yml", "docs", "tests",
31+
{ path = "mkdocs.yml", format = "sdist" },
32+
{ path = "docs", format = "sdist" },
33+
{ path = "tests", format = "sdist" },
34+
]
2135

2236
[tool.poetry.dependencies]
2337
python = "^3.8"
2438
cookiecutter = "^2.1.1"
39+
typer = "^0.9.0"
40+
pydantic = "^2.5.2"
2541

2642
[tool.poetry.group.dev.dependencies]
2743
poethepoet = "^0.18.1"
@@ -48,6 +64,9 @@ anybadge = "^1.14.0"
4864
interrogate = "^1.5.0"
4965
black = "^23.3.0"
5066

67+
[tool.poetry.scripts]
68+
fair-python-cookiecutter = "fair_python_cookiecutter.main:app"
69+
5170
[build-system]
5271
requires = ["poetry-core"]
5372
build-backend = "poetry.core.masonry.api"
@@ -63,14 +82,46 @@ docs = "mkdocs build" # run this to generate local documentation
6382
# -------------------
6483

6584
[tool.pytest.ini_options]
85+
pythonpath = ["src"]
6686
addopts = "--ignore='{{ cookiecutter.__project_slug }}'"
87+
# addopts = "--cov-report=term-missing:skip-covered"
88+
filterwarnings = [
89+
"ignore::DeprecationWarning:pkg_resources.*",
90+
"ignore::DeprecationWarning:pyshacl.*",
91+
# Example:
92+
# "ignore::DeprecationWarning:importlib_metadata.*",
93+
]
6794

68-
[tool.flake8]
69-
ignore = ["W503"]
70-
max-line-length = 88
95+
[tool.coverage.run]
96+
source = ["fair_python_cookiecutter"]
7197

72-
[tool.pydocstyle]
73-
convention = "google"
98+
[tool.coverage.report]
99+
exclude_lines = [
100+
"pragma: no cover",
101+
"def __repr__",
102+
"if self.debug:",
103+
"if settings.DEBUG",
104+
"raise AssertionError",
105+
"raise NotImplementedError",
106+
"if 0:",
107+
"if TYPE_CHECKING:",
108+
"if __name__ == .__main__.:",
109+
"class .*\\bProtocol\\):",
110+
"@(abc\\.)?abstractmethod",
111+
]
112+
113+
[tool.ruff.lint]
114+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
115+
select = ["E4", "E7", "E9", "F"]
116+
ignore = []
117+
# TODO: check that ruff substitutes
118+
# - flake8-bugbear
119+
# - dlint
120+
# - pydocstyle (google style)
121+
# - black
122+
# - autoflake
123+
# - isort
74124

75125
[tool.bandit]
76126
exclude_dirs = ["tests"]
127+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""somesy package."""
2+
import importlib_metadata
3+
4+
# Set version, it will use version from pyproject.toml if defined
5+
__version__: str = importlib_metadata.version(__package__ or __name__)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Main entry point for the somesy CLI."""
2+
import logging
3+
4+
import typer
5+
from cookiecutter.config import get_user_config
6+
7+
logger = logging.getLogger("fair_python_cookiecutter")
8+
9+
app = typer.Typer()
10+
11+
12+
@app.command()
13+
def main():
14+
"""Main entry point for creating a project from the template."""
15+
typer.echo("hello world!")
16+
17+
conf = get_user_config()
18+
print(conf.get("fair-python-cookiecutter"))

{{ cookiecutter.__project_slug }}/.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ jobs:
7272
strategy:
7373
fail-fast: true
7474
matrix:
75-
os: [ "ubuntu-latest" ]
76-
python-version: [ "3.8", "3.9", "3.10" ]
75+
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
76+
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
7777
runs-on: ${{ matrix.os }}
7878

7979
steps:

0 commit comments

Comments
 (0)