Compare commits

..

5 Commits

Author SHA1 Message Date
c50cfe88d6 Add pytest to dev dependencies;
upgrade dev dependencies;
remove unnecessary main test script entrypoint;
remove unnecessary line from `.gitignore`;
put repo description variable into top-level `__init__.py`;
introduce syntax-error as a reminder to fix copyright;
add CSS fix for broken inline-code segments;
update `index.md` layout;
reorder linting script calls and add a bit more output;
support Python 3.8+ by default;
fix wrong dependency file reference in `pyproject.toml`;
add `pytest` config to `pyproject.toml`;
call `pytest` in `coverage` config;
add a few sensible rule-ignores to `ruff` config
2023-10-27 12:20:41 +02:00
1a293563d1 Upgrade dev dependencies;
upgrade to newer reusable Github workflow;
rename requirements files;
add `ruff` linting rules;
add `black` config for line length 80
2023-10-16 17:34:07 +02:00
acf4c06404 Upgrade dev dependencies; leave more forced placeholders 2023-07-14 11:22:37 +02:00
1c49c4923f Add generic .cache to .gitignore 2023-06-24 20:36:43 +02:00
9f89f8cc9d Add relevant links to home/readme page 2023-06-24 20:34:46 +02:00
12 changed files with 111 additions and 67 deletions

View File

@ -8,9 +8,9 @@ on:
jobs:
test:
name: Test
uses: daniil-berg/reusable-workflows/.github/workflows/python-test.yaml@v0.2.1
uses: daniil-berg/reusable-workflows/.github/workflows/python-test.yaml@v0.2.2
with:
versions: '["3.9", "3.10", "3.11"]'
versions: '["3.9", "3.10", "3.11", "3.12"]'
unittest-command: 'scripts/test.sh'
coverage-command: 'scripts/cov.sh'
unittest-requirements: "-e '.[dev]'"
@ -24,7 +24,7 @@ jobs:
name: Release
if: ${{ github.ref_type == 'tag' }}
needs: test
uses: daniil-berg/reusable-workflows/.github/workflows/python-release.yaml@v0.2.1
uses: daniil-berg/reusable-workflows/.github/workflows/python-release.yaml@v0.2.2
with:
git-ref: ${{ github.ref_name }}
secrets:

7
.gitignore vendored
View File

@ -18,8 +18,5 @@
__pycache__/
*.py[cod]
# Testing:
/.coverage
# mypy:
.mypy_cache/
# Miscellaneous cache:
.cache/

View File

@ -0,0 +1,3 @@
.md-typeset code {
word-break: keep-all; /* Prevent inline-code from being broken up. */
}

View File

@ -1,15 +1,29 @@
# ${REPO_NAME}
${REPO_DESCRIPTION}
**${REPO_DESCRIPTION}**
## Usage
---
...
[📑 Documentation][1]   |   [🧑‍💻 Source Code][2]   |   [🐛 Bug Tracker][3]
---
## Installation
`pip install ${REPO_NAME}`
## Usage
...
## Dependencies
Python Version ..., OS ...
Python `>=3.8`, OS agnostic
---
© 2023 ...
[1]: https://${REPO_OWNER_LOWER}.github.io/${REPO_NAME_LOWER}
[2]: https://github.com/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}
[3]: https://github.com/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}/issues

View File

@ -1,4 +1,4 @@
copyright: "© 2023 ${REPO_OWNER_TITLE}"
... copyright: "© 2023 ..."
site_name: "${REPO_NAME}"
site_description: "${REPO_DESCRIPTION}"
site_url: "http://${REPO_OWNER_LOWER}.github.io/${REPO_NAME_LOWER}"

View File

@ -2,19 +2,22 @@
# Python packaging: #
[build-system]
requires = ["setuptools", "setuptools-scm"]
requires = [
"setuptools",
"setuptools-scm",
]
build-backend = "setuptools.build_meta"
[project]
name = "${REPO_NAME}"
description = "${REPO_DESCRIPTION}"
authors = [
{ name = "${REPO_OWNER_TITLE}", email = ... },
{ name = ..., email = ... },
]
maintainers = [
{ name = "${REPO_OWNER_TITLE}", email = ... },
{ name = ..., email = ... },
]
requires-python = ">=3.9, <4.0"
requires-python = ">=3.8, <4.0"
keywords = [
...
]
@ -39,18 +42,17 @@ dynamic = [
]
[project.optional-dependencies]
full = [
...
]
full = []
dev = [
"black==23.3.0",
"build==0.10.0",
"coverage[toml]==7.2.7",
"black==23.10.1",
"build==1.0.3",
"coverage[toml]==7.3.2",
"isort==5.12.0",
"mkdocs-material==9.1.17",
"mkdocstrings[python]==0.22.0",
"mypy==1.4.0",
"ruff==0.0.275",
"mkdocs-material==9.4.6",
"mkdocstrings[python]==0.23.0",
"mypy==1.5.1",
"pytest==7.4.3",
"ruff==0.1.3",
]
[project.urls]
@ -59,9 +61,9 @@ dev = [
"Documentation" = "http://${REPO_OWNER_LOWER}.github.io/${REPO_NAME_LOWER}"
[tool.setuptools.dynamic]
dependencies = { file = "requirements/common.txt" }
dependencies = { file = "requirements/base.txt" }
readme = { file = ["README.md"], content-type = "text/markdown" }
version = {attr = ..."${REPO_NAME}.__version__"}
version = { attr = ..."${REPO_NAME}.__version__" }
#########################
# Static type checking: #
@ -75,8 +77,16 @@ files = [
warn_unused_configs = true
strict = true
show_error_codes = true
plugins = [
...
plugins = []
############
# Testing: #
[tool.pytest.ini_options]
cache_dir = ".cache/pytest"
addopts = "-ra -v"
testpaths = [
"tests",
]
#######################
@ -88,7 +98,7 @@ source = [
"src/",
]
branch = true
command_line = "-m tests"
command_line = "-m pytest -qq"
omit = [
".venv*/*",
]
@ -111,25 +121,45 @@ omit = [
[tool.ruff]
cache-dir = ".cache/ruff"
select = [
"F", # pyflakes
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"N", # pep8-naming
"D", # pydocstyle
"C", # flake8-comprehensions
"ANN", # flake8-annotations
"S", # flake8-bandit
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
"C", # flake8-comprehensions
"PIE", # flake8-pie
"T20", # flake8-print
"RET", # flake8-return
"SIM", # flake8-simplify
"TD", # flake8-todos
"TCH", # flake8-type-checking
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
"ERA", # eradicate
"PL", # pylint
"TRY", # tryceratops
"RUF", # ruff-specific
]
ignore = [
"E501", # Line too long -> handled by black
"D203", # 1 blank line required before class docstring -> D211 is better
"D212", # Multi-line docstring summary should start at the first line -> ugly, D212 is better
"D401", # First line of docstring should be in imperative mood -> no, it shouldn't
"D407", # Missing dashed underline after section -> different docstring style
"E501", # Line too long -> handled by black
"D203", # 1 blank line required before class docstring -> D211 is better
"D212", # Multi-line docstring summary should start at the first line -> ugly, D213 is better
"D401", # First line of docstring should be in imperative mood -> no, it shouldn't
"D407", # Missing dashed underline after section -> different docstring style
"ANN101", # Missing type annotation for self in method -> unnecessary
"ANN102", # Missing type annotation for cls in classmethod -> unnecessary
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed -> we'll use it sparingly
"N818", # Exception name should be named with an Error suffix -> absolutely not
]
[tool.ruff.per-file-ignores]
"src/**/__init__.py" = [
"A001", # Variable {name} is shadowing a Python builtin
"D104", # Missing docstring in public package
"F401", # {...} imported but unused
]
@ -137,12 +167,23 @@ ignore = [
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"S101", # Use of `assert` detected
"FBT", # flake8-boolean-trap
"TRY", # tryceratops
]
####################
# Code formatting: #
[tool.black]
line_length = 80
###################
# Import sorting: #
[tool.isort]
profile = "black"
extra_standard_library = ["typing_extensions"]
line_length = 80

View File

@ -1,9 +1,10 @@
-r common.txt
black==23.3.0
build==0.10.0
coverage[toml]==7.2.7
-r full.txt
black==23.10.1
build==1.0.3
coverage[toml]==7.3.2
isort==5.12.0
mkdocs-material==9.1.17
mkdocstrings[python]==0.22.0
mypy==1.4.0
ruff==0.0.275
mkdocs-material==9.4.6
mkdocstrings[python]==0.23.0
mypy==1.5.1
pytest==7.4.3
ruff==0.1.3

1
requirements/full.txt Normal file
View File

@ -0,0 +1 @@
-r base.txt

View File

@ -5,13 +5,13 @@ source "$(dirname $(realpath $0))/util.sh"
echo 'Linting source and test files...'
echo ' isort - consistent imports'
isort src/ tests/ --check-only
echo ' ruff - extensive linting'
echo ' ruff - Doing extensive linting'
ruff src/ tests/
echo ' black - consistent style'
echo ' black - Ensuring consistent code style'
run_and_capture black src/ tests/ --check
echo ' isort - Ensuring consistent import structure'
isort src/ tests/ --check-only
echo -e "${bold_green}No issues found${color_reset}\n"

View File

@ -1,4 +1,4 @@
__copyright__ = "© 2023 ${REPO_OWNER_TITLE}"
... __copyright__ = "© 2023 ..."
__license__ = """Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
@ -16,5 +16,5 @@ limitations under the License."""
__version__ = "0.0.1"
__doc__ = """
PLACEHOLDER
${REPO_DESCRIPTION}
"""

View File

@ -1,13 +0,0 @@
import sys
import unittest
if __name__ == "__main__":
try:
pattern = sys.argv[1]
except IndexError:
pattern = "test*.py"
test_suite = unittest.defaultTestLoader.discover(".", pattern=pattern)
test_runner = unittest.TextTestRunner(resultclass=unittest.TextTestResult)
result = test_runner.run(test_suite)
sys.exit(not result.wasSuccessful())