From 75fdb22fec0d408e7142d248638c484fdb870c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szczepan=20Cie=C5=9Blik?= Date: Mon, 6 Apr 2026 19:05:27 +0200 Subject: [PATCH] Rework tasks and docs generation --- .envrc | 1 + .github/workflows/docs.yml | 25 ++++++++++++++++++ .github/workflows/test.yml | 5 ---- HISTORY.rst | 2 +- Makefile | 52 -------------------------------------- README.rst | 2 +- devbin/build-docs | 4 +++ docs/spelling_wordlist.txt | 3 +++ docs/usage.rst | 2 +- jsonmodels/__init__.py | 6 +++++ pyproject.toml | 10 -------- tests/__init__.py | 11 -------- tests/test_project.py | 46 --------------------------------- 13 files changed, 42 insertions(+), 127 deletions(-) create mode 100644 .envrc create mode 100644 .github/workflows/docs.yml delete mode 100644 Makefile create mode 100755 devbin/build-docs delete mode 100644 tests/test_project.py diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..097daf9 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +PATH_add devbin diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..ab51ce8 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,25 @@ +name: Docs + +on: [pull_request] + +jobs: + docs: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install enchant and dictionary + run: | + sudo apt-get -qq update + sudo apt-get -y install enchant-2 hunspell-en-us + + - name: Install dependencies + run: pip install .[dev] + + - name: Build docs + run: devbin/build-docs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 20abd3e..dd1dd1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,11 +31,6 @@ jobs: restore-keys: | ${{ matrix.os }}-${{ matrix.python-version }}-v1- - - name: Install enchant - run: | - sudo apt-get -qq update - sudo apt-get -y install enchant-2 - - name: Install dependencies run: | python -m pip install -U pip diff --git a/HISTORY.rst b/HISTORY.rst index 7ba415d..6638fc7 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -31,7 +31,7 @@ History 2.5.0 (2021-07-26) ++++++++++++++++++ -* Improvied error messages for field validation errors. +* Improvised error messages for field validation errors. * Allowed to validate non model list items. * Added DictField. diff --git a/Makefile b/Makefile deleted file mode 100644 index b73cc86..0000000 --- a/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -.PHONY: clean-pyc clean-build docs clean - -help: - @echo "clean-build - remove build artifacts" - @echo "clean-pyc - remove Python file artifacts" - @echo "lint - check style with flake8" - @echo "test - run tests quickly with the default Python" - @echo "coverage - check code coverage quickly with the default Python" - @echo "docs - generate Sphinx HTML documentation, including API docs" - @echo "release - package and upload a release" - @echo "sdist - package" - -clean: clean-build clean-pyc - rm -fr htmlcov/ - -clean-build: - rm -fr build/ - rm -fr dist/ - rm -fr *.egg-info - -clean-pyc: - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - -lint: - flake8 jsonmodels tests - -test: - python setup.py test - -coverage: - python setup.py test - coverage html - open htmlcov/index.html - -docs: - rm -f docs/jsonmodels.rst - rm -f docs/modules.rst - sphinx-apidoc -o docs/ jsonmodels - $(MAKE) -C docs clean - $(MAKE) -C docs html - open docs/_build/html/index.html - -release: clean - python setup.py sdist upload - python setup.py bdist_wheel upload - -dist: clean - python setup.py sdist - python setup.py bdist_wheel - ls -l dist diff --git a/README.rst b/README.rst index 6fd5f00..8acda73 100644 --- a/README.rst +++ b/README.rst @@ -398,7 +398,7 @@ that can be expressed in json schema if you want to be 100% correct on schema si * Dealing with schemaless data -(Plese note that using schemaless fields can cause your models to get out of control - especially if +(Please note that using schemaless fields can cause your models to get out of control - especially if you are the one responsible for data schema. On the other hand there is usually the case when incomming data are with no schema defined and schemaless fields are the way to go.) diff --git a/devbin/build-docs b/devbin/build-docs new file mode 100755 index 0000000..b20fae6 --- /dev/null +++ b/devbin/build-docs @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail + +sphinx-build -b spelling -d docs/_build/doctress docs docs/build/spelling diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index b72b7dd..ba94e6f 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -5,8 +5,10 @@ explicite django docstring docstrings +Garimort indices jsonmodels +jsonschema kwargs metaclass namedtuple @@ -16,3 +18,4 @@ szczepan regex validator validators +virtualenv diff --git a/docs/usage.rst b/docs/usage.rst index 46ab17b..7102132 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -249,7 +249,7 @@ is possible to you to operate just on models. >>> person = Person() >>> schema = person.to_json_schema() -And thats it! You can serve then this schema through your API or use it for +And that's it! You can serve then this schema through your API or use it for validation incoming data. Different names in structure and objects diff --git a/jsonmodels/__init__.py b/jsonmodels/__init__.py index e69de29..7f28bc7 100644 --- a/jsonmodels/__init__.py +++ b/jsonmodels/__init__.py @@ -0,0 +1,6 @@ +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version("jsonmodels") +except PackageNotFoundError: + __version__ = "unknown" diff --git a/pyproject.toml b/pyproject.toml index 1d0e44f..f4390ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,13 +32,8 @@ dev = [ "Sphinx", "coverage", "docutils", - "flake8", - "flake8-pyproject", "invoke", "isort", - "mccabe", - "pep8", - "pyflakes", "pytest", "pytest-cov", "sphinxcontrib-spelling", @@ -47,10 +42,5 @@ dev = [ [project.urls] "Home" = "https://github.com/jazzband/jsonmodels" -[tool.flake8] -exclude = ["./docs/conf.py"] -max-complexity = 8 -max_line_length = 88 - [tool.isort] profile = "black" diff --git a/tests/__init__.py b/tests/__init__.py index 9607881..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,11 +0,0 @@ -def _have_flake8(): - try: - import flake8 # noqa: F401 - - return True - except ImportError: - return False - - -LINT = _have_flake8() -CHECK_SPELLING = False diff --git a/tests/test_project.py b/tests/test_project.py deleted file mode 100644 index cd54547..0000000 --- a/tests/test_project.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import re -import subprocess - -import pytest -from invoke import run - -import tests - -root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -source_dir = os.path.join(root_dir, "jsonmodels") -tests_dir = os.path.join(root_dir, "tests") - - -@pytest.mark.skipif(not tests.LINT, reason="No lint tests.") -def test_pep8_and_complexity(): - result = [] - for filename in _collect_static([source_dir, tests_dir]): - result.append(subprocess.call(["flake8", filename])) - - if any(result): - raise RuntimeError("Tests for PEP8 compliance and complexity have failed!") - - -@pytest.mark.skipif( - not tests.LINT or not tests.CHECK_SPELLING, reason="No spelling check." -) -def test_docs(): - run("sphinx-build -b spelling -d docs/_build/doctress docs docs/build/spelling") - - -def _collect_static(dirs): - matches = [] - for dir_ in dirs: - _collect_recursively(dir_, matches) - return matches - - -def _collect_recursively(directory, result): - for name in os.listdir(directory): - if not re.search("^\\.", name): - fullpath = os.path.join(directory, name) - if re.search("\\.py$", name): - result.append(fullpath) - elif os.path.isdir(fullpath): - _collect_recursively(fullpath, result)