Skip to content

Commit 839e307

Browse files
authored
Merge branch 'main' into patch-1
2 parents 358b68d + 7204aef commit 839e307

File tree

96 files changed

+1671
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1671
-524
lines changed

.codespellignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
udo
2+
anchestors

.cookiecutter.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"cookiecutter": {
3+
"_checkout": null,
4+
"_output_dir": "/Users/c0fec0de/projects",
5+
"_repo_dir": "/Users/c0fec0de/.cookiecutters/python-template",
6+
"_template": "gh:nbiotcloud/python-template",
7+
"name": "anytree",
8+
"snake_name": "anytree",
9+
"title": "Powerful and Lightweight Python Tree Data Structure with various plugins",
10+
"user": "c0fec0de",
11+
"year": "2016"
12+
}
13+
}

.github/workflows/main.yml

+43-30
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,67 @@
1-
name: test
2-
1+
name: main
32
on: [push, pull_request, release]
4-
53
jobs:
6-
build:
7-
4+
test:
5+
runs-on: ${{ matrix.os }}
86
strategy:
97
matrix:
10-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
11-
runs-on: ubuntu-latest
8+
os:
9+
- "ubuntu-latest"
10+
- "macos-latest"
11+
# - "windows-latest"
12+
python-version:
13+
- "3.9"
14+
- "3.10"
15+
- "3.11"
16+
- "3.12"
17+
- "3.13"
1218
steps:
13-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
1420
- name: Set up Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v4
21+
uses: astral-sh/setup-uv@v5
1622
with:
23+
version: "0.6.9"
1724
python-version: ${{ matrix.python-version }}
18-
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip
21-
sudo apt-get install -y graphviz
22-
pip install tox "poetry>=1.4" coveralls
23-
- name: TOX
24-
run: tox
25+
enable-cache: true
26+
cache-dependency-glob: "uv.lock"
27+
- name: Install graphviz
28+
run: sudo apt install -y graphviz || true
29+
- name: Run all
30+
run: make all
2531
- name: Upload coverage data to coveralls.io
26-
run: coveralls --service=github
32+
run: uv run --frozen -- coveralls --service=github
2733
env:
2834
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2935
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
3036
COVERALLS_PARALLEL: true
3137

3238
coveralls:
3339
name: Indicate completion to coveralls.io
34-
needs: build
40+
needs: test
3541
runs-on: ubuntu-latest
36-
container: python:3-slim
3742
steps:
38-
- name: Finished
39-
run: |
40-
pip3 install --upgrade coveralls
41-
coveralls --service=github --finish
42-
env:
43-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
- uses: actions/checkout@v4
44+
- name: Set up Python ${{ matrix.python-version }}
45+
uses: astral-sh/setup-uv@v5
46+
with:
47+
version: "0.6.9"
48+
python-version: ${{ matrix.python-version }}
49+
enable-cache: true
50+
cache-dependency-glob: "uv.lock"
51+
- name: Upload coverage data to coveralls.io
52+
run: uv run --frozen -- coveralls --service=github --finish
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4455

4556
publish:
4657
if: github.event_name == 'push' && github.ref_type == 'tag'
4758
needs: coveralls
59+
name: upload release to PyPI
4860
runs-on: ubuntu-latest
61+
permissions:
62+
id-token: write
4963
steps:
50-
- uses: actions/checkout@v3
51-
- name: Build and publish to pypi
52-
uses: JRubics/[email protected]
53-
with:
54-
pypi_token: ${{ secrets.PYPI_TOKEN }}
64+
- uses: actions/checkout@v4
65+
- uses: pdm-project/setup-pdm@v4
66+
- name: Publish package distributions to PyPI
67+
run: pdm publish

.gitignore

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
*.egg-info/
2-
*.xml
1+
__pycache__
2+
.*_cache/
33
.coverage
4-
.tox
5-
.venv
4+
.coverage*
5+
.DS_Store
6+
.hypothesis
67
.mypy_cache
8+
.nox/
9+
.pdm-python
10+
.test2ref
11+
.tox
12+
.venv*
13+
*.egg-info/
14+
*.pyc
15+
*.xml
716
/.vscode
8-
__pycache__
9-
build
17+
build/
1018
dist/
1119
docs/_readthedocs/
1220
poetry.lock
21+
report.xml
1322
setup.py

.pre-commit-config.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
exclude: ^tests/refdata/.*
2+
repos:
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
# Ruff version.
5+
rev: v0.11.2
6+
hooks:
7+
# Run the linter.
8+
- id: ruff
9+
args: [--fix]
10+
# Run the formatter.
11+
- id: ruff-format
12+
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v5.0.0
15+
hooks:
16+
- id: trailing-whitespace
17+
- id: end-of-file-fixer
18+
- id: check-yaml
19+
- id: check-toml
20+
- id: check-json
21+
- id: check-xml
22+
- id: debug-statements
23+
- id: check-added-large-files
24+
- id: check-merge-conflict
25+
- id: mixed-line-ending
26+
27+
- repo: https://github.com/Lucas-C/pre-commit-hooks
28+
rev: v1.5.5
29+
hooks:
30+
- id: remove-tabs
31+
args: [--whitespaces-count, "2"] # defaults to: 4
32+
# - id: insert-license
33+
# files: \.py$
34+
# args:
35+
# - --license-filepath
36+
# - LICENSE
37+
# - --use-current-year
38+
39+
- repo: https://github.com/codespell-project/codespell
40+
rev: v2.4.1
41+
hooks:
42+
- id: codespell
43+
args:
44+
- "--write-changes"
45+
- "--ignore-words=.codespellignore"
46+
additional_dependencies:
47+
- tomli
48+
exclude: '^uv\.lock$'

.readthedocs.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ version: 2
88
build:
99
os: ubuntu-22.04
1010
tools:
11-
python: "3.9"
11+
python: "3.11"
1212

1313
commands:
1414
- pip install --upgrade --no-cache-dir pip
15-
- pip install --no-cache-dir "poetry>=1.4" "crashtest==0.4.1"
16-
- poetry install --with=doc --without=test
17-
- poetry run make html -C docs
15+
- pip install --no-cache-dir uv
16+
- make doc
17+
- mkdir _readthedocs
1818
- cp -r docs/build _readthedocs

CONTRIBUTING.md

+54-23
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,72 @@
1-
# Contribute
1+
# CONTRIBUTING
22

3-
## Branches
3+
Please follow github workflow. Create a ticket and/or branch. Create a pull-request.
44

5-
* `2.x.x` main line for `2.x.x`
6-
* `3.x.x` main line for `3.x.x`
7-
* documentation links refer to `3.x.x`
8-
* 2.x.x can be merged to 3.x.x
9-
* `main`
10-
* 2.x.x can be merged to main
5+
## Local Development
116

12-
## Testing
7+
### Installation
138

14-
### Create Environment
9+
Please install these tools:
1510

16-
Run these commands just the first time:
11+
* [`uv` Installation](https://docs.astral.sh/uv/getting-started/installation/)
12+
* [`make`](https://www.gnu.org/software/make/)
13+
* [`git`](https://git-scm.com/)
14+
* [Visual Studio Code](https://code.visualstudio.com/)
15+
* [`graphviz`](https://graphviz.org/)
16+
17+
18+
### Editor
19+
Start Visual Studio Code:
1720

1821
```bash
19-
# Ensure python3 is installed
20-
python3 -m venv .venv
21-
source .venv/bin/activate
22-
pip install tox "poetry>=1.4" "crashtest==0.4.1"
22+
make code
2323
```
2424

25-
### Enter Environment
25+
### Testing
2626

27-
Run this command once you open a new shell:
27+
Run auto-formatting, linting, tests and documentation build:
2828

2929
```bash
30-
source .venv/bin/activate
30+
make all
3131
```
3232

33-
### Test Your Changes
33+
See `make help` for any further details.
34+
35+
Please note that `tests/refdata` contains reference data from test runs.
36+
`make test2refdata` updates this directory.
37+
38+
## Project Structure
39+
40+
The project contains these files and directories:
41+
42+
| File/Directory | Description |
43+
|---|---|
44+
| `src/` | Python Package Sources - the files this is all about |
45+
| `pyproject.toml` | Python Package Meta File. Also contains all tool settings |
46+
| `.gitignore` | Lists of files and directories ignored by version control system |
47+
| `.github/` | Github Settings |
48+
| `.readthedocs.yaml` | Documentation Server Configuration |
49+
| `.pre-commit-config.yaml` | Pre-Commit Check Configuration |
50+
| `uv.lock` | File with resolved python package dependencies |
51+
52+
Next to that, there are some temporary files ignored by version control system.
53+
54+
| File/Directory | Description |
55+
|---|---|
56+
| `htmlcov/` | Test Execution Code Coverage Report in HTML format |
57+
| `report.xml` | Test Execution Report |
58+
| `.venv` | Virtual Environments |
59+
60+
61+
## Branches
62+
63+
* `2.x.x` main line for `2.x.x`
64+
* `3.x.x` main line for `3.x.x`
65+
* documentation links refer to `3.x.x`
66+
* 2.x.x can be merged to 3.x.x
67+
* `main`
68+
* 2.x.x can be merged to main
3469

35-
```bash
36-
# test
37-
tox
38-
```
3970

4071
### Release
4172

Makefile

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
_GREEN:=\033[0;32m
2+
_BLUE:=\033[0;34m
3+
_BOLD:=\033[1m
4+
_NORM:=\033[0m
5+
ENV:=uv run --frozen --
6+
PYTEST_OPTIONS=
7+
8+
9+
.PHONY: help
10+
help: ## [DEFAULT] Show this help
11+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?##"}; {printf "${_BLUE}${_BOLD}%-10s${_NORM} %s\n", $$1, $$2}'
12+
13+
14+
.PHONY: all
15+
all: ## Do everything taggged with [ALL] below
16+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep "\[ALL\]" | grep -v "^all" | awk 'BEGIN {FS = ":.*?##"}; {printf "%s ", $$1}' | xargs make
17+
@echo "\n ${_GREEN}${_BOLD}PASS${_NORM}\n"
18+
19+
20+
.PHONY: pre-commit
21+
pre-commit: .venv/.valid .git/hooks/pre-commit ## [ALL] Run 'pre-commit' on all files
22+
${ENV} pre-commit run --all-files
23+
24+
.git/hooks/pre-commit: .venv/.valid
25+
${ENV} pre-commit install --install-hooks
26+
27+
28+
.PHONY: test
29+
test: .venv/.valid ## [ALL] Run Unittests via 'pytest' with {PYTEST_OPTIONS}
30+
${ENV} pytest -vv ${PYTEST_OPTIONS}
31+
@echo "See coverage report:\n\n file://${PWD}/htmlcov/index.html\n"
32+
33+
34+
.PHONY: test2refdata
35+
test2refdata: .venv/.valid ## Run Unittests via 'pytest' with {PYTEST_OPTIONS} and update tests/refdata
36+
rm -rf tests/refdata
37+
touch .test2ref
38+
${ENV} pytest -vv ${PYTEST_OPTIONS}
39+
@echo "See coverage report:\n\n file://${PWD}/htmlcov/index.html\n"
40+
rm .test2ref
41+
42+
43+
.PHONY: checktypes
44+
checktypes: .venv/.valid ## [ALL] Run Type-Checking via 'mypy'
45+
${ENV} mypy src
46+
47+
48+
.PHONY: doc
49+
doc: .venv/.valid ## [ALL] Build Documentation via 'mkdocs'
50+
${ENV} make html -C docs
51+
52+
53+
.PHONY: code
54+
code: ## Start Visual Studio Code
55+
code anytree.code-workspace &
56+
57+
58+
.PHONY: clean
59+
clean: ## Remove everything mentioned by '.gitignore' file
60+
git clean -Xdf
61+
62+
63+
.PHONY: distclean
64+
distclean: ## Remove everything mentioned by '.gitignore' file and UNTRACKED files
65+
git clean -xdf
66+
67+
68+
.PHONY: shell
69+
shell: ## Open a project specific SHELL. For leaving use 'exit'.
70+
${ENV} ${SHELL}
71+
72+
73+
# Helper
74+
.venv/.valid: pyproject.toml uv.lock
75+
uv sync --frozen
76+
@touch $@
77+
78+
uv.lock:
79+
uv lock

README.rst

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
.. image:: https://coveralls.io/repos/github/c0fec0de/anytree/badge.svg
1111
:target: https://coveralls.io/github/c0fec0de/anytree
1212

13-
.. image:: https://readthedocs.org/projects/anytree/badge/?version=stable
14-
:target: https://anytree.readthedocs.io/en/stable
15-
1613
.. image:: https://api.codeclimate.com/v1/badges/e6d325d6fd23a93aab20/maintainability
1714
:target: https://codeclimate.com/github/c0fec0de/anytree/maintainability
1815
:alt: Maintainability

0 commit comments

Comments
 (0)