Skip to content

Commit

Permalink
Merge pull request #42 from kanedata/python3.13
Browse files Browse the repository at this point in the history
Add python 3.13 support
  • Loading branch information
drkane authored Jul 12, 2024
2 parents 7698311 + d094f09 commit 646e6ff
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 15 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 9 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,9 +17,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: pip
- 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
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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}"
Expand Down Expand Up @@ -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:.}"]
Expand Down

0 comments on commit 646e6ff

Please sign in to comment.