From cd49c55979b4382de04e5a8e13642b55f2d88787 Mon Sep 17 00:00:00 2001 From: David Kane Date: Fri, 12 Jul 2024 09:35:07 +0100 Subject: [PATCH 1/4] test python 3.13 support --- .github/workflows/run-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8603405..df868bd 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,7 +8,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-beta.3"] steps: - uses: actions/checkout@v4 @@ -17,6 +17,9 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: pip + - name: Install needed libraries + run: | + sudo apt-get install -y libxml2-dev libxslt-dev - name: Install dependencies run: | pip install -e . From e019118927845b82e001337a7f89e3e0ea71b655 Mon Sep 17 00:00:00 2001 From: David Kane Date: Fri, 12 Jul 2024 09:49:12 +0100 Subject: [PATCH 2/4] remove hatch from github actions --- .github/workflows/linting.yml | 8 +++++--- .github/workflows/run-tests.yml | 10 ++++++---- pyproject.toml | 12 +++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 87a576f..b483b5e 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -19,7 +19,9 @@ jobs: cache: pip - name: Install dependencies run: | - pip install -e . - pip install hatch + pip install -e .[lint] - name: Lint - run: hatch run lint:all + run: | + ruff check . + ruff format --check --diff . + mypy --install-types --non-interactive src/ixbrlparse tests diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index df868bd..572eff5 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,12 +17,14 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: pip - - name: Install needed libraries + - name: Install libraries for LXML run: | sudo apt-get install -y libxml2-dev libxslt-dev - name: Install dependencies run: | - pip install -e . - pip install hatch + pip install -e .[test] - name: Run tests - run: hatch run cov-fail + run: | + coverage run -m pytest tests + - coverage combine + coverage report --fail-under=95 diff --git a/pyproject.toml b/pyproject.toml index 92b0a9b..274a34c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,8 @@ dependencies = [ [project.optional-dependencies] docs = ["mkdocs", "mkdocs-material", "mkdocstrings[python]"] +test = ["coverage[toml]>=6.5", "pytest"] +lint = ["mypy>=1.0.0", "ruff>=0.4.7", "types-beautifulsoup4", "types-click"] [project.urls] Homepage = "https://github.com/kanedata/ixbrl-parse" @@ -45,7 +47,7 @@ ixbrlparse = "ixbrlparse.cli:ixbrlparse" path = "src/ixbrlparse/__about__.py" [tool.hatch.envs.default] -dependencies = ["coverage[toml]>=6.5", "pytest"] +features = ["test"] [tool.hatch.envs.default.scripts] test = "pytest {args:tests}" @@ -74,12 +76,8 @@ deploy = "mkdocs gh-deploy --force" [tool.hatch.envs.lint] detached = true -dependencies = [ - "mypy>=1.0.0", - "ruff>=0.4.7", - "types-beautifulsoup4", - "types-click", -] +features = ["lint"] + [tool.hatch.envs.lint.scripts] typing = "mypy --install-types --non-interactive {args:src/ixbrlparse tests}" style = ["ruff check {args:.}", "ruff format --check --diff {args:.}"] From 72d44f007752533d26f6791dc0391910f02388d5 Mon Sep 17 00:00:00 2001 From: David Kane Date: Fri, 12 Jul 2024 09:51:06 +0100 Subject: [PATCH 3/4] tweak to tests --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 572eff5..8a3f948 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -26,5 +26,5 @@ jobs: - name: Run tests run: | coverage run -m pytest tests - - coverage combine + coverage combine coverage report --fail-under=95 From d094f09b8e2e0d7e6db14ba7b0eaf6e91a98813a Mon Sep 17 00:00:00 2001 From: David Kane Date: Fri, 12 Jul 2024 10:02:15 +0100 Subject: [PATCH 4/4] add details without hatch --- README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f299088..eb5325d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ and [XBRL International](https://www.xbrl.org/). This tool is not affiliated wit The module requires [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) and [lxml](https://lxml.de/) to parse the documents. +If you're using Python 3.13 you may need to ensure that the `libxml2-dev` and `libxslt-dev` packages have been installed. + [word2number](https://github.com/akshaynagpal/w2n) is used to process the numeric items with the `numsenwords` format. @@ -60,7 +62,7 @@ You can also use as a python module (see [the documentation](https://ixbrl-parse ## Development -The module is setup for development using [hatch](https://hatch.pypa.io/latest/). +The module is setup for development using [hatch](https://hatch.pypa.io/latest/). It should be possible to run tests and linting without needed hatch, however. ### Run tests @@ -70,6 +72,13 @@ Tests can be run with `pytest`: hatch run test ``` +Without hatch, you'll need to run: + +```bash +pip install -e .[test] +python -m pytest tests +``` + ### Test coverage Run tests then report on coverage @@ -78,18 +87,43 @@ Run tests then report on coverage hatch run cov ``` +Without hatch, you'll need to run: + +```bash +pip install -e .[test] +coverage run -m pytest tests +coverage report +``` + Run tests then run a server showing where coverage is missing ```bash hatch run cov-html ``` +Without hatch, you'll need to run: + +```bash +pip install -e .[test] +coverage run -m pytest tests +coverage report +coverage html +python -m http.server -d htmlcov +``` + ### Run typing checks ```bash hatch run lint:typing ``` +Without hatch, you'll need to run: + +```bash +pip install -e .[lint] +mypy --install-types --non-interactive src/ixbrlparse tests +``` + ### Linting Ruff should be run before committing any changes. @@ -100,18 +134,43 @@ To check for any changes needed: hatch run lint:style ``` +Without hatch, you'll need to run: + +```bash +pip install -e .[lint] +ruff check . +ruff format --check --diff . +``` + To run any autoformatting possible: ```sh hatch run lint:fmt ``` +Without hatch, you'll need to run: + +```bash +pip install -e .[lint] +ruff format . +ruff check --fix . +``` + ### Run all checks at once ```sh hatch run lint:all ``` +Without hatch, you'll need to run: + +```bash +pip install -e .[lint] +ruff check . +ruff format --check --diff . +mypy --install-types --non-interactive src/ixbrlparse tests +``` + ## Publish to pypi ```bash