-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: cleanup project add mypy, update linters and dependencies
- Loading branch information
Showing
10 changed files
with
362 additions
and
265 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
default_stages: [commit] | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-added-large-files | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.12.1 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.1.14 | ||
hooks: | ||
- id: ruff | ||
|
||
- repo: https://github.com/compilerla/conventional-pre-commit | ||
rev: v3.1.0 | ||
hooks: | ||
- id: conventional-pre-commit | ||
stages: [commit-msg] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
.PHONY: help tests quality coverage coverage-html | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: help | ||
help: ## List all the command helps. | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
|
||
tests: ## Run tests. | ||
@poetry run pytest tests/ -x -vv | ||
@poetry run mypy sutoppu.py | ||
.PHONY: init-pre-commit | ||
init-pre-commit: ## Init pre-commit. | ||
@pre-commit install | ||
@pre-commit install --hook-type commit-msg | ||
|
||
.PHONY: tests | ||
test: ## Run tests. | ||
@pytest -vv | ||
@mypy | ||
|
||
quality: ## Check quality. | ||
@poetry run flake8 | ||
@poetry run black --check sutoppu.py | ||
.PHONY: lint | ||
lint: ## Check linter. | ||
@pre-commit run --all-files | ||
|
||
format: ## Format files. | ||
@poetry run black sutoppu.py | ||
.PHONY: coverage-html | ||
coverage-html: ## Run pytest with html output coverage. | ||
@pytest --cov-report html | ||
|
||
coverage: ## Run tests with coverage. | ||
@poetry run pytest tests/ --cov=sutoppu | ||
.PHONY: ci | ||
ci: lint test ## Run CI. | ||
|
||
coverage-html: ## Run tests with html output coverage. | ||
@poetry run pytest tests/ --cov=sutoppu --cov-report html | ||
.PHONY: bump-version | ||
bump-version: check-version ## Bump version, define target version with "VERSION=*.*.*". | ||
@sed -i "s/^\(version = \"\)\(.\)*\"/\1${VERSION}\"/" pyproject.toml | ||
@echo "Version replaced by ${VERSION} in 'pyproject.toml'" | ||
|
||
ci: quality coverage ## Run CI. | ||
check-version: | ||
ifndef VERSION | ||
$(error VERSION is undefined) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
[tool.poetry] | ||
name = "sutoppu" | ||
|
||
version = "1.0.0" | ||
description = "A simple python implementation of Specification pattern." | ||
authors = ["u8slvn <[email protected]>"] | ||
|
||
license = "MIT" | ||
readme = "README.md" | ||
packages = [{include = "sutoppu.py", from = "src"}] | ||
repository = "https://github.com/u8slvn/sutoppu" | ||
homepage = "https://github.com/u8slvn/sutoppu" | ||
|
||
classifiers = [ | ||
"Intended Audience :: Developers", | ||
"Development Status :: 5 - Production/Stable", | ||
|
@@ -32,7 +30,6 @@ keywords=[ | |
"business-rules", | ||
"verification", | ||
] | ||
|
||
include = [ | ||
"LICENSE", | ||
"CHANGELOG.md", | ||
|
@@ -45,11 +42,52 @@ python = "^3.8.1" | |
[tool.poetry.dev-dependencies] | ||
pytest-cov = "^4.0.0" | ||
pytest-mock = "^3.10.0" | ||
flake8 = "^6.0.0" | ||
black = "^23.1.0" | ||
pytest = "^7.2.2" | ||
mypy = "^1.1.1" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
mypy = "^1.8.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.mypy] | ||
files = "src/" | ||
mypy_path = "src/" | ||
namespace_packages = true | ||
show_error_codes = true | ||
ignore_missing_imports = true | ||
strict = true | ||
|
||
[tool.black] | ||
line_length = 88 | ||
|
||
[tool.ruff] | ||
fix = true | ||
line-length = 88 | ||
extend-select = [ | ||
"I", # isort | ||
"N", # pep8-naming | ||
] | ||
|
||
[tool.ruff.isort] | ||
force-single-line = true | ||
lines-between-types = 1 | ||
lines-after-imports = 2 | ||
required-imports = [ | ||
"from __future__ import annotations", | ||
] | ||
|
||
[tool.coverage.report] | ||
exclude_lines = [ | ||
"raise NotImplementedError", | ||
] | ||
|
||
[tool.pytest.ini_options] | ||
pythonpath = "src/" | ||
testpaths = ["tests"] | ||
addopts = [ | ||
"--cov=src/", | ||
"--import-mode=importlib", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.