Compare commits

..

1 commit

Author SHA1 Message Date
123ff77aad Update dependency pytest to v8
All checks were successful
build package and container / build-pypackage (pull_request) Successful in 13s
check code / check-docs (pull_request) Successful in 7s
create release / release-pypackage (pull_request) Successful in 25s
build package and container / build-container (pull_request) Successful in 3m4s
check code / check-code-py38 (pull_request) Successful in 7m24s
check code / scan-code-py311 (pull_request) Has been skipped
check code / check-code-py39 (pull_request) Successful in 7m19s
check code / check-code-py310 (pull_request) Successful in 7m0s
check code / check-code-py311 (pull_request) Successful in 6m54s
2024-02-17 08:16:30 +01:00
9 changed files with 119 additions and 83 deletions

View file

@ -30,27 +30,30 @@ jobs:
- name: build package - name: build package
run: hatch build --clean run: hatch build --clean
- name: get release notes - name: create release notes
id: release-notes run: bash get_release_notes.sh latest
uses: olofvndrhr/releasenote-gen@v1
- name: read changelog
id: changelog
uses: juliangruber/read-file-action@v1
with:
path: ./RELEASENOTES.md
- name: create gitea release - name: create gitea release
uses: https://gitea.com/actions/release-action@main uses: https://gitea.com/actions/release-action@main
if: gitea.event_name != 'pull_request' if: gitea.event_name != 'pull_request'
with: with:
title: ${{ gitea.ref_name }} title: ${{ gitea.ref_name }}
body: ${{ steps.release-notes.outputs.releasenotes }} body: ${{ steps.changelog.outputs.content }}
files: |- files: |-
dist/** dist/**
- name: create github release - name: create github release
uses: ncipollo/release-action@v1 uses: softprops/action-gh-release@v1
if: gitea.event_name != 'pull_request' if: gitea.event_name != 'pull_request'
with: with:
token: ${{ secrets.GH_TOKEN }} token: ${{ secrets.GH_TOKEN }}
owner: olofvndrhr title: ${{ gitea.ref_name }}
repo: manga-dlp body: ${{ steps.changelog.outputs.content }}
name: ${{ gitea.ref_name }} files: |-
body: ${{ steps.release-notes.outputs.releasenotes }}
artifacts: |-
dist/** dist/**

View file

@ -1,4 +1,4 @@
from typing import Dict, List from typing import Dict, List, Union
from mangadlp.models import ChapterData, ComicInfo from mangadlp.models import ChapterData, ComicInfo
@ -40,7 +40,7 @@ class YourAPI:
self.manga_uuid = "abc" self.manga_uuid = "abc"
self.manga_title = "abc" self.manga_title = "abc"
self.chapter_list = ["1", "2", "2.1", "5", "10"] self.chapter_list = ["1", "2", "2.1", "5", "10"]
self.manga_chapter_data: Dict[str, ChapterData] = { # example data self.manga_chapter_data: dict[str, ChapterData] = { # example data
"1": { "1": {
"uuid": "abc", "uuid": "abc",
"volume": "1", "volume": "1",
@ -57,7 +57,7 @@ class YourAPI:
}, },
} }
# or with --forcevol # or with --forcevol
self.manga_chapter_data: Dict[str, ChapterData] = { self.manga_chapter_data: dict[str, ChapterData] = {
"1:1": { "1:1": {
"uuid": "abc", "uuid": "abc",
"volume": "1", "volume": "1",
@ -72,7 +72,7 @@ class YourAPI:
}, },
} }
def get_chapter_images(self, chapter: str, wait_time: float) -> List[str]: def get_chapter_images(self, chapter: str, wait_time: float) -> list[str]:
"""Get chapter images as a list (full links). """Get chapter images as a list (full links).
Args: Args:

52
get_release_notes.sh Executable file
View file

@ -0,0 +1,52 @@
#!/bin/bash
# shellcheck disable=SC2016
# script to extract the release notes from the changelog
# show script help
function show_help() {
cat << EOF
Script to generate release-notes from a changelog (CHANGELOG.md)
Usage:
./get_release_notes.sh <new_version>
Example:
./get_release_notes.sh "2.0.5"
or
./get_release_notes.sh "latest"
EOF
exit 0
}
# create changelog for release
function get_release_notes() {
local l_version="${1}"
printf 'Creating release-notes\n'
# check for version
if [[ -z "${l_version}" ]]; then
printf 'You need to specify a version with $1\n'
exit 1
fi
if [[ ${l_version,,} == "latest" ]]; then
l_version="$(grep -o -E "^##\s\[[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}\]" CHANGELOG.md | head -n 1 | grep -o -E "[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}")"
fi
awk -v ver="[${l_version}]" \
'/^## / { if (p) { exit }; if ($2 == ver) { p=1 } } p && NF' \
'CHANGELOG.md' > 'RELEASENOTES.md'
printf 'Done\n'
}
# check options
case "${1}" in
'--help' | '-h' | 'help')
show_help
;;
*)
get_release_notes "${@}"
;;
esac

View file

@ -6,7 +6,7 @@ set shell := ["bash", "-uc"]
set dotenv-load set dotenv-load
show_receipts: show_receipts:
just --list @just --list
show_system_info: show_system_info:
@echo "==================================" @echo "=================================="
@ -18,58 +18,58 @@ show_system_info:
@echo "==================================" @echo "=================================="
setup: setup:
asdf install @asdf install
lefthook install @lefthook install
create_venv: create_venv:
@echo "creating venv" @echo "creating venv"
python3 -m pip install --upgrade pip setuptools wheel @python3 -m pip install --upgrade pip setuptools wheel
python3 -m venv venv @python3 -m venv venv
install_deps: install_deps:
@echo "installing dependencies" @echo "installing dependencies"
python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt @python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt
pip3 install -r /tmp/requirements.txt @pip3 install -r /tmp/requirements.txt
install_deps_dev: install_deps_dev:
@echo "installing dev dependencies" @echo "installing dev dependencies"
python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt @python3 -m hatch dep show requirements --project-only > /tmp/requirements.txt
python3 -m hatch dep show requirements --env-only >> /tmp/requirements.txt @python3 -m hatch dep show requirements --env-only >> /tmp/requirements.txt
pip3 install -r /tmp/requirements.txt @pip3 install -r /tmp/requirements.txt
create_reqs: create_reqs:
@echo "creating requirements" @echo "creating requirements"
pipreqs --force --savepath requirements.txt src/mangadlp/ @pipreqs --force --savepath requirements.txt src/mangadlp/
test_shfmt: test_shfmt:
find . -type f \( -name "**.sh" -and -not -path "./.**" -and -not -path "./venv**" \) -exec shfmt -d -i 4 -bn -ci -sr "{}" \+; @find . -type f \( -name "**.sh" -and -not -path "./.**" -and -not -path "./venv**" \) -exec shfmt -d -i 4 -bn -ci -sr "{}" \+;
format_shfmt: format_shfmt:
find . -type f \( -name "**.sh" -and -not -path "./.**" -and -not -path "./venv**" \) -exec shfmt -w -i 4 -bn -ci -sr "{}" \+; @find . -type f \( -name "**.sh" -and -not -path "./.**" -and -not -path "./venv**" \) -exec shfmt -w -i 4 -bn -ci -sr "{}" \+;
lint: lint:
just show_system_info just show_system_info
just test_shfmt just test_shfmt
hatch run lint:style @hatch run lint:style
hatch run lint:typing @hatch run lint:typing
format: format:
just show_system_info just show_system_info
just format_shfmt just format_shfmt
hatch run lint:fmt @hatch run lint:fmt
check: check:
just lint
just format just format
just lint
test: test:
hatch run default:test @hatch run default:test
coverage: coverage:
hatch run default:cov @hatch run default:cov
build: build:
hatch build --clean @hatch build --clean
run loglevel *flags: run loglevel *flags:
hatch run mangadlp --loglevel {{loglevel}} {{flags}} @hatch run mangadlp --loglevel {{loglevel}} {{flags}}

View file

@ -45,20 +45,20 @@ source = "regex_commit"
path = "src/mangadlp/__about__.py" path = "src/mangadlp/__about__.py"
tag_sign = false tag_sign = false
[tool.hatch.build]
ignore-vcs = true
[tool.hatch.build.targets.sdist] [tool.hatch.build.targets.sdist]
packages = ["src/mangadlp"] packages = ["src/mangadlp"]
[tool.hatch.build.targets.wheel] [tool.hatch.build.targets.wheel]
packages = ["src/mangadlp"] packages = ["src/mangadlp"]
###
### envs ### envs
###
[tool.hatch.envs.default] [tool.hatch.envs.default]
python = "3.11"
dependencies = [ dependencies = [
"pytest==8.0.2", "pytest==8.0.1",
"coverage==7.3.2", "coverage==7.3.2",
"xmltodict>=0.13.0", "xmltodict>=0.13.0",
"xmlschema>=2.2.1", "xmlschema>=2.2.1",
@ -76,26 +76,17 @@ python = ["3.8", "3.9", "3.10", "3.11"]
[tool.hatch.envs.lint] [tool.hatch.envs.lint]
detached = true detached = true
dependencies = [ dependencies = [
"mypy==1.8.0", "mypy==1.7.1",
"ruff==0.2.2", "ruff==0.1.7",
] ]
[tool.hatch.envs.lint.scripts] [tool.hatch.envs.lint.scripts]
typing = "mypy --non-interactive --install-types {args:src/mangadlp}" typing = "mypy --non-interactive --install-types {args:src/mangadlp}"
style = [ style = ["ruff check --diff {args:src/mangadlp}", "ruff format --check --diff {args:src/mangadlp}"]
"ruff check --diff {args:.}", fmt = ["ruff format {args:src/mangadlp}", "ruff check --fix {args:src/mangadlp}", "style"]
"ruff format --check --diff {args:.}"
]
fmt = [
"ruff check --fix {args:.}",
"ruff format {args:.}",
"style"
]
all = ["style", "typing"] all = ["style", "typing"]
###
### ruff ### ruff
###
[tool.ruff] [tool.ruff]
target-version = "py38" target-version = "py38"
@ -103,6 +94,7 @@ line-length = 100
indent-width = 4 indent-width = 4
fix = true fix = true
show-fixes = true show-fixes = true
ignore-init-module-imports = true
respect-gitignore = true respect-gitignore = true
src = ["src", "tests"] src = ["src", "tests"]
exclude = [ exclude = [
@ -120,7 +112,6 @@ exclude = [
"dist", "dist",
"node_modules", "node_modules",
"venv", "venv",
"contrib"
] ]
[tool.ruff.lint] [tool.ruff.lint]
@ -151,7 +142,6 @@ select = [
"W", "W",
"YTT", "YTT",
] ]
ignore-init-module-imports = true
ignore = ["E501", "D103", "D100", "D102", "PLR2004", "D403", "ISC001", "FBT001", "FBT002", "FBT003", "W505"] ignore = ["E501", "D103", "D100", "D102", "PLR2004", "D403", "ISC001", "FBT001", "FBT002", "FBT003", "W505"]
unfixable = ["F401"] unfixable = ["F401"]
@ -160,42 +150,39 @@ quote-style = "double"
indent-style = "space" indent-style = "space"
skip-magic-trailing-comma = false skip-magic-trailing-comma = false
line-ending = "lf" line-ending = "lf"
docstring-code-format = true
[tool.ruff.lint.per-file-ignores] [tool.ruff.per-file-ignores]
"__init__.py" = ["D104"] "__init__.py" = ["D104"]
"__about__.py" = ["D104", "F841"] "__about__.py" = ["D104", "F841"]
"tests/**/*" = ["PLR2004", "S101", "TID252", "T201", "ARG001", "S603", "S605"] "tests/**/*" = ["PLR2004", "S101", "TID252"]
[tool.ruff.lint.pyupgrade] [tool.ruff.pyupgrade]
keep-runtime-typing = true keep-runtime-typing = true
[tool.ruff.lint.isort] [tool.ruff.isort]
lines-after-imports = 2 lines-after-imports = 2
known-first-party = ["mangadlp"] known-first-party = ["mangadlp"]
[tool.ruff.lint.flake8-tidy-imports] [tool.ruff.flake8-tidy-imports]
ban-relative-imports = "all" ban-relative-imports = "all"
[tool.ruff.lint.pylint] [tool.ruff.pylint]
max-branches = 24 max-branches = 24
max-returns = 12 max-returns = 12
max-statements = 100 max-statements = 100
max-args = 15 max-args = 15
allow-magic-value-types = ["str", "bytes", "complex", "float", "int"] allow-magic-value-types = ["str", "bytes", "complex", "float", "int"]
[tool.ruff.lint.mccabe] [tool.ruff.mccabe]
max-complexity = 15 max-complexity = 15
[tool.ruff.lint.pydocstyle] [tool.ruff.pydocstyle]
convention = "google" convention = "google"
[tool.ruff.lint.pycodestyle] [tool.ruff.pycodestyle]
max-doc-length = 100 max-doc-length = 100
###
### mypy ### mypy
###
[tool.mypy] [tool.mypy]
#plugins = ["pydantic.mypy"] #plugins = ["pydantic.mypy"]
@ -217,20 +204,16 @@ show_error_context = true
#init_typed = true #init_typed = true
#warn_required_dynamic_aliases = true #warn_required_dynamic_aliases = true
###
### pytest ### pytest
###
[tool.pytest.ini_options] [tool.pytest.ini_options]
pythonpath = ["src"] pythonpath = ["src"]
addopts = "--color=yes --exitfirst --verbose -ra" addopts = "--color=yes --exitfirst --verbose -ra"
#addopts = "--color=yes --exitfirst --verbose -ra --capture=tee-sys"
filterwarnings = [ filterwarnings = [
'ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning', 'ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning',
] ]
###
### coverage ### coverage
###
[tool.coverage.run] [tool.coverage.run]
source_pkgs = ["mangadlp", "tests"] source_pkgs = ["mangadlp", "tests"]
@ -239,8 +222,8 @@ parallel = true
omit = ["src/mangadlp/__about__.py"] omit = ["src/mangadlp/__about__.py"]
[tool.coverage.paths] [tool.coverage.paths]
mangadlp = ["src/mangadlp", "*/manga-dlp/src/mangadlp"] testproj = ["src/mangadlp", "*/mangadlp/src/mangadlp"]
tests = ["tests", "*/manga-dlp/tests"] tests = ["tests", "*/mangadlp/tests"]
[tool.coverage.report] [tool.coverage.report]
# Regexes for lines to exclude from consideration # Regexes for lines to exclude from consideration

View file

@ -1,6 +1,5 @@
import shutil import shutil
from pathlib import Path from pathlib import Path
from typing import List
import pytest import pytest
import requests import requests
@ -19,7 +18,7 @@ def test_downloader():
] ]
chapter_path = Path("tests/test_folder1") chapter_path = Path("tests/test_folder1")
chapter_path.mkdir(parents=True, exist_ok=True) chapter_path.mkdir(parents=True, exist_ok=True)
images: List[str] = [] images: list[str] = []
downloader.download_chapter(urls, str(chapter_path), 2) downloader.download_chapter(urls, str(chapter_path), 2)
for file in chapter_path.iterdir(): for file in chapter_path.iterdir():
images.append(file.name) images.append(file.name)

View file

@ -52,7 +52,7 @@ def test_no_volume():
def test_readin_list(): def test_readin_list():
list_file = "tests/test_list.txt" list_file = "tests/test_list.txt"
test_list = mdlpinput.readin_list(None, None, list_file) test_list = mdlpinput.readin_list(None, None, list_file)
assert test_list == [ assert test_list == [
"https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu", "https://mangadex.org/title/a96676e5-8ae2-425e-b549-7f15dd34a6d8/komi-san-wa-komyushou-desu",

View file

@ -389,11 +389,11 @@ def test_chapter_metadata():
forcevol = False forcevol = False
test = Mangadex(url_uuid, language, forcevol) test = Mangadex(url_uuid, language, forcevol)
chapter_metadata = test.create_metadata("1") chapter_metadata = test.create_metadata("1")
manga_name = chapter_metadata["Series"] manga_name = chapter_metadata["Series"]
chapter_name = chapter_metadata["Title"] chapter_name = chapter_metadata["Title"]
chapter_num = chapter_metadata["Number"] chapter_num = chapter_metadata["Number"]
chapter_volume = chapter_metadata["Volume"] chapter_volume = chapter_metadata["Volume"]
chapter_url = chapter_metadata["Web"] chapter_url = chapter_metadata["Web"]
assert (manga_name, chapter_name, chapter_volume, chapter_num, chapter_url) == ( assert (manga_name, chapter_name, chapter_volume, chapter_num, chapter_url) == (
"Komi-san wa Komyushou Desu", "Komi-san wa Komyushou Desu",

View file

@ -3,7 +3,6 @@ import platform
import shutil import shutil
import time import time
from pathlib import Path from pathlib import Path
from typing import List
import pytest import pytest
from pytest import MonkeyPatch from pytest import MonkeyPatch
@ -166,7 +165,7 @@ def test_full_with_input_skip_folder(wait_10s: MonkeyPatch):
chapter_path.mkdir(parents=True, exist_ok=True) chapter_path.mkdir(parents=True, exist_ok=True)
os.system(f"python3 {script_path} {command_args}") os.system(f"python3 {script_path} {command_args}")
found_files: List[str] = [] found_files: list[str] = []
for file in chapter_path.iterdir(): for file in chapter_path.iterdir():
found_files.append(file.name) found_files.append(file.name)