d8s-python 0.8.0__tar.gz → 0.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {d8s_python-0.8.0 → d8s_python-0.10.0}/.coveragerc +0 -1
- d8s_python-0.10.0/.github/dependabot.yml +8 -0
- d8s_python-0.8.0/.github/workflows/pytest.yml → d8s_python-0.10.0/.github/workflows/ci.yml +33 -17
- d8s_python-0.10.0/.github/workflows/dependabot-auto-merge.yml +67 -0
- d8s_python-0.10.0/.github/workflows/lint.yml +32 -0
- d8s_python-0.10.0/.github/workflows/release-please.yml +51 -0
- d8s_python-0.10.0/.release-please-manifest.json +3 -0
- d8s_python-0.10.0/AGENTS.md +38 -0
- d8s_python-0.10.0/CHANGELOG.md +8 -0
- d8s_python-0.10.0/CLAUDE.md +1 -0
- d8s_python-0.10.0/PKG-INFO +305 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/README.md +1 -1
- d8s_python-0.10.0/d8s_python/__init__.py +6 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/d8s_python/ast_data.py +61 -60
- {d8s_python-0.8.0 → d8s_python-0.10.0}/d8s_python/python_data.py +83 -38
- d8s_python-0.10.0/docker/lint.sh +19 -0
- d8s_python-0.10.0/pyproject.toml +69 -0
- d8s_python-0.10.0/release-please-config.json +24 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/tests/test_ast_data.py +124 -129
- {d8s_python-0.8.0 → d8s_python-0.10.0}/tests/test_python_data.py +133 -97
- d8s_python-0.10.0/uv.lock +1275 -0
- d8s_python-0.8.0/.github/dependabot.yml +0 -9
- d8s_python-0.8.0/.github/workflows/lint.yaml +0 -26
- d8s_python-0.8.0/.github/workflows/pypi-publish.yml +0 -34
- d8s_python-0.8.0/Dockerfile +0 -9
- d8s_python-0.8.0/PKG-INFO +0 -297
- d8s_python-0.8.0/bumpversion.dockerfile +0 -9
- d8s_python-0.8.0/d8s_python/__init__.py +0 -6
- d8s_python-0.8.0/d8s_python.egg-info/PKG-INFO +0 -297
- d8s_python-0.8.0/d8s_python.egg-info/SOURCES.txt +0 -34
- d8s_python-0.8.0/d8s_python.egg-info/dependency_links.txt +0 -1
- d8s_python-0.8.0/d8s_python.egg-info/requires.txt +0 -10
- d8s_python-0.8.0/d8s_python.egg-info/top_level.txt +0 -2
- d8s_python-0.8.0/d8s_python.egg-info/zip-safe +0 -1
- d8s_python-0.8.0/docker/lint.sh +0 -20
- d8s_python-0.8.0/docker-compose.yml +0 -46
- d8s_python-0.8.0/mypy.ini +0 -2
- d8s_python-0.8.0/pyproject.toml +0 -20
- d8s_python-0.8.0/requirements.txt +0 -8
- d8s_python-0.8.0/requirements_dev.txt +0 -11
- d8s_python-0.8.0/setup.cfg +0 -22
- d8s_python-0.8.0/setup.py +0 -45
- {d8s_python-0.8.0 → d8s_python-0.10.0}/.editorconfig +0 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/.github/workflows/new-issues-to-backlog-project.yml +0 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/.gitignore +0 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/COPYING +0 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/COPYING.LESSER +0 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/conftest.py +0 -0
- {d8s_python-0.8.0 → d8s_python-0.10.0}/tests/__init__.py +0 -0
|
@@ -9,48 +9,64 @@ on:
|
|
|
9
9
|
pull_request:
|
|
10
10
|
branches: [ main ]
|
|
11
11
|
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
12
16
|
jobs:
|
|
13
|
-
|
|
17
|
+
build_smoke:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- name: Set up Python 3.14
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: '3.14'
|
|
25
|
+
- name: Set up uv
|
|
26
|
+
uses: astral-sh/setup-uv@v6
|
|
27
|
+
- name: Build package
|
|
28
|
+
run: uv build
|
|
14
29
|
|
|
30
|
+
build_multi_os:
|
|
15
31
|
runs-on: ${{ matrix.os }}
|
|
16
32
|
strategy:
|
|
17
33
|
matrix:
|
|
18
34
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
19
|
-
python-version: [3.
|
|
35
|
+
python-version: ['3.14']
|
|
20
36
|
|
|
21
37
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
38
|
+
- uses: actions/checkout@v4
|
|
23
39
|
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
-
uses: actions/setup-python@
|
|
40
|
+
uses: actions/setup-python@v5
|
|
25
41
|
with:
|
|
26
42
|
python-version: ${{ matrix.python-version }}
|
|
43
|
+
- name: Set up uv
|
|
44
|
+
uses: astral-sh/setup-uv@v6
|
|
27
45
|
- name: Install dependencies
|
|
28
|
-
run:
|
|
29
|
-
python -m pip install -r requirements.txt
|
|
30
|
-
python -m pip install -r requirements_dev.txt
|
|
46
|
+
run: uv sync --locked --group dev
|
|
31
47
|
- name: Run pytest
|
|
32
48
|
run: |
|
|
33
|
-
pytest
|
|
34
|
-
codecov
|
|
49
|
+
uv run pytest
|
|
50
|
+
uv run codecov
|
|
35
51
|
|
|
36
52
|
build_multi_py_versions:
|
|
37
53
|
runs-on: ${{ matrix.os }}
|
|
38
54
|
strategy:
|
|
39
55
|
matrix:
|
|
40
56
|
os: [ubuntu-latest]
|
|
41
|
-
python-version: [3.
|
|
57
|
+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
|
|
42
58
|
|
|
43
59
|
steps:
|
|
44
|
-
- uses: actions/checkout@
|
|
60
|
+
- uses: actions/checkout@v4
|
|
45
61
|
- name: Set up Python ${{ matrix.python-version }}
|
|
46
|
-
uses: actions/setup-python@
|
|
62
|
+
uses: actions/setup-python@v5
|
|
47
63
|
with:
|
|
48
64
|
python-version: ${{ matrix.python-version }}
|
|
65
|
+
- name: Set up uv
|
|
66
|
+
uses: astral-sh/setup-uv@v6
|
|
49
67
|
- name: Install dependencies
|
|
50
|
-
run:
|
|
51
|
-
python -m pip install -r requirements.txt
|
|
52
|
-
python -m pip install -r requirements_dev.txt
|
|
68
|
+
run: uv sync --locked --group dev
|
|
53
69
|
- name: Run pytest
|
|
54
70
|
run: |
|
|
55
|
-
pytest
|
|
56
|
-
codecov
|
|
71
|
+
uv run pytest
|
|
72
|
+
uv run codecov
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Dependabot auto-merge
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
schedule:
|
|
6
|
+
- cron: "11 11 * * *"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
label:
|
|
15
|
+
if: github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- name: Fetch Dependabot metadata
|
|
19
|
+
id: meta
|
|
20
|
+
uses: dependabot/fetch-metadata@v2
|
|
21
|
+
|
|
22
|
+
- name: Ensure labels exist
|
|
23
|
+
env:
|
|
24
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
25
|
+
run: |
|
|
26
|
+
gh label create auto-merge-candidate --color ededed --description "Dependabot dev-dep PR eligible for auto-merge after soak" --force --repo "$GITHUB_REPOSITORY"
|
|
27
|
+
gh label create needs-manual-merge --color d93f0b --description "Dependabot PR not eligible for auto-merge; needs manual review" --force --repo "$GITHUB_REPOSITORY"
|
|
28
|
+
|
|
29
|
+
- name: Label auto-merge candidates
|
|
30
|
+
if: steps.meta.outputs.dependency-type == 'direct:development' && (steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor')
|
|
31
|
+
env:
|
|
32
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
33
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
34
|
+
run: gh pr edit "$PR_URL" --add-label auto-merge-candidate
|
|
35
|
+
|
|
36
|
+
- name: Label PRs needing manual review
|
|
37
|
+
if: ${{ !(steps.meta.outputs.dependency-type == 'direct:development' && (steps.meta.outputs.update-type == 'version-update:semver-patch' || steps.meta.outputs.update-type == 'version-update:semver-minor')) }}
|
|
38
|
+
env:
|
|
39
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
40
|
+
PR_URL: ${{ github.event.pull_request.html_url }}
|
|
41
|
+
run: gh pr edit "$PR_URL" --add-label needs-manual-merge
|
|
42
|
+
|
|
43
|
+
soak-and-merge:
|
|
44
|
+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
env:
|
|
47
|
+
SOAK_DAYS: 3
|
|
48
|
+
steps:
|
|
49
|
+
- name: Enable auto-merge on soaked PRs
|
|
50
|
+
env:
|
|
51
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
52
|
+
run: |
|
|
53
|
+
cutoff=$(date -u -d "${SOAK_DAYS} days ago" +%Y-%m-%dT%H:%M:%SZ)
|
|
54
|
+
gh pr list \
|
|
55
|
+
--repo "$GITHUB_REPOSITORY" \
|
|
56
|
+
--author "app/dependabot" \
|
|
57
|
+
--label auto-merge-candidate \
|
|
58
|
+
--state open \
|
|
59
|
+
--json number,createdAt,autoMergeRequest \
|
|
60
|
+
--jq ".[] | select(.createdAt < \"$cutoff\") | .number" \
|
|
61
|
+
| while read -r pr; do
|
|
62
|
+
auto=$(gh pr view "$pr" --repo "$GITHUB_REPOSITORY" --json autoMergeRequest --jq .autoMergeRequest)
|
|
63
|
+
if [ "$auto" = "null" ] || [ -z "$auto" ]; then
|
|
64
|
+
echo "Enabling auto-merge on PR #$pr"
|
|
65
|
+
gh pr merge "$pr" --auto --squash --repo "$GITHUB_REPOSITORY" || echo "Failed to enable auto-merge on PR #$pr"
|
|
66
|
+
fi
|
|
67
|
+
done
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# This workflow will install Python dependencies and lint the code with ruff and mypy
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Lint
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ main ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ main ]
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: '3.14'
|
|
25
|
+
- name: Set up uv
|
|
26
|
+
uses: astral-sh/setup-uv@v6
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --locked --group dev
|
|
29
|
+
- name: Lint
|
|
30
|
+
env:
|
|
31
|
+
CONTEXT: ci
|
|
32
|
+
run: ./docker/lint.sh
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Conventional-commit release automation.
|
|
2
|
+
# On every push to main, release-please maintains a release PR (CHANGELOG +
|
|
3
|
+
# version bump in pyproject.toml + d8s_lists/__init__.py). Merging that PR
|
|
4
|
+
# tags vX.Y.Z and creates the GitHub Release; this same run then builds and
|
|
5
|
+
# publishes to PyPI via OIDC.
|
|
6
|
+
#
|
|
7
|
+
# Publish is folded into THIS workflow on purpose: a tag pushed by
|
|
8
|
+
# release-please uses GITHUB_TOKEN, which does NOT trigger a separate
|
|
9
|
+
# tag-triggered workflow. Gating on release_created keeps OIDC (no PAT/secrets).
|
|
10
|
+
|
|
11
|
+
name: release-please
|
|
12
|
+
|
|
13
|
+
on:
|
|
14
|
+
push:
|
|
15
|
+
branches:
|
|
16
|
+
- main
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: write # create release PR, tag, and GitHub Release
|
|
20
|
+
pull-requests: write # open/update the release PR
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
release-please:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
outputs:
|
|
26
|
+
release_created: ${{ steps.release.outputs.release_created }}
|
|
27
|
+
tag_name: ${{ steps.release.outputs.tag_name }}
|
|
28
|
+
steps:
|
|
29
|
+
- uses: googleapis/release-please-action@v4
|
|
30
|
+
id: release
|
|
31
|
+
with:
|
|
32
|
+
config-file: release-please-config.json
|
|
33
|
+
manifest-file: .release-please-manifest.json
|
|
34
|
+
|
|
35
|
+
publish:
|
|
36
|
+
needs: release-please
|
|
37
|
+
if: needs.release-please.outputs.release_created == 'true'
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
permissions:
|
|
40
|
+
id-token: write # required for OIDC trusted publishing
|
|
41
|
+
contents: read
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
with:
|
|
45
|
+
ref: ${{ needs.release-please.outputs.tag_name }}
|
|
46
|
+
- name: Set up uv
|
|
47
|
+
uses: astral-sh/setup-uv@v6
|
|
48
|
+
- name: Build
|
|
49
|
+
run: uv build
|
|
50
|
+
- name: Publish to PyPI
|
|
51
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Commit messages: use Conventional Commits
|
|
4
|
+
|
|
5
|
+
Releases are automated by [release-please](https://github.com/googleapis/release-please).
|
|
6
|
+
It reads commit messages to bump the version, write `CHANGELOG.md`, tag, and publish to
|
|
7
|
+
PyPI. **Non-conventional commits are silently ignored** — no version bump, absent from the
|
|
8
|
+
changelog.
|
|
9
|
+
|
|
10
|
+
Format: `type: description` (optionally `type(scope): description`).
|
|
11
|
+
|
|
12
|
+
Common types and their effect on the release:
|
|
13
|
+
|
|
14
|
+
| Type | Effect | Changelog section |
|
|
15
|
+
|------|--------|-------------------|
|
|
16
|
+
| `feat:` | minor bump (0.8.0 → 0.9.0) | Features |
|
|
17
|
+
| `fix:` | patch bump (0.8.0 → 0.8.1) | Bug Fixes |
|
|
18
|
+
| `perf:` | patch bump | Performance Improvements |
|
|
19
|
+
| `deps:` | no bump (rides next release) | Dependencies |
|
|
20
|
+
| `docs:` `refactor:` `test:` `chore:` `ci:` `build:` `style:` | no bump | hidden |
|
|
21
|
+
|
|
22
|
+
Breaking change: append `!` (`feat!: ...`) or add a `BREAKING CHANGE:` footer → major bump.
|
|
23
|
+
|
|
24
|
+
Examples:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
feat: add iterable_chunk
|
|
28
|
+
fix: cycle() returns empty when length is 0
|
|
29
|
+
feat!: rename list_flatten to iterable_flatten
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Prefer squash-merging PRs so the PR title becomes the single conventional commit.
|
|
33
|
+
|
|
34
|
+
## Releasing
|
|
35
|
+
|
|
36
|
+
Don't bump versions, edit `CHANGELOG.md`, or create tags by hand — release-please owns all
|
|
37
|
+
three. To cut a release, merge the open `chore: release X.Y.Z` PR; that tags the version,
|
|
38
|
+
creates the GitHub Release, and publishes to PyPI via OIDC.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.10.0](https://github.com/democritus-project/d8s-python/compare/v0.9.0...v0.10.0) (2026-07-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* modernize tooling and release automation ([893b0eb](https://github.com/democritus-project/d8s-python/commit/893b0ebf92e8740f1c666405352a32c642af3df6))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Read AGENTS.md in the repository root and follow it.
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: d8s_python
|
|
3
|
+
Version: 0.10.0
|
|
4
|
+
Summary: Democritus functions for working with Python code.
|
|
5
|
+
Project-URL: Source, https://github.com/democritus-project/d8s-python
|
|
6
|
+
Project-URL: Issues, https://github.com/democritus-project/d8s-python/issues
|
|
7
|
+
Author: Floyd Hightower
|
|
8
|
+
License: GNU Lesser General Public License v3
|
|
9
|
+
License-File: COPYING
|
|
10
|
+
License-File: COPYING.LESSER
|
|
11
|
+
Keywords: abstract-syntax-tree,ast,democritus,python,python-ast,python-asts,python-asts-utility,utility
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
15
|
+
Classifier: Natural Language :: English
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: d8s-algorithms<1.0,>=0.7.0
|
|
24
|
+
Requires-Dist: d8s-file-system<1.0,>=0.10.0
|
|
25
|
+
Requires-Dist: d8s-grammars<1.0,>=0.6.0
|
|
26
|
+
Requires-Dist: d8s-lists<1.0,>=0.8.0
|
|
27
|
+
Requires-Dist: d8s-strings<1.0,>=0.5.0
|
|
28
|
+
Requires-Dist: jinja2<4.0,>=3.1.6
|
|
29
|
+
Requires-Dist: more-itertools<12.0,>=11.1.0
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Democritus Python
|
|
33
|
+
|
|
34
|
+
[](https://pypi.python.org/pypi/d8s-python)
|
|
35
|
+
[](https://github.com/democritus-project/d8s-python/actions)
|
|
36
|
+
[](https://github.com/democritus-project/d8s-python/actions)
|
|
37
|
+
[](https://codecov.io/gh/democritus-project/d8s-python)
|
|
38
|
+
[](https://semver.org/spec/v2.0.0.html)
|
|
39
|
+
[](https://github.com/astral-sh/ruff)
|
|
40
|
+
[](https://choosealicense.com/licenses/lgpl-3.0/)
|
|
41
|
+
|
|
42
|
+
Democritus functions<sup>[1]</sup> for working with Python data (code and ASTs).
|
|
43
|
+
|
|
44
|
+
[1] Democritus functions are <i>simple, effective, modular, well-tested, and well-documented</i> Python functions.
|
|
45
|
+
|
|
46
|
+
We use `d8s` (pronounced "dee-eights") as an abbreviation for `democritus` (you can read more about this [here](https://github.com/democritus-project/roadmap#what-is-d8s)).
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
pip install d8s-python
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
You import the library like:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from d8s_python import *
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Once imported, you can use any of the functions listed below.
|
|
63
|
+
|
|
64
|
+
## Functions
|
|
65
|
+
|
|
66
|
+
- ```python
|
|
67
|
+
def python_functions_signatures(
|
|
68
|
+
code_text: str,
|
|
69
|
+
*,
|
|
70
|
+
ignore_private_functions: bool = False,
|
|
71
|
+
ignore_nested_functions: bool = False,
|
|
72
|
+
keep_function_name: bool = False,
|
|
73
|
+
) -> List[str]:
|
|
74
|
+
"""Return the function signatures for all of the functions in the given code_text."""
|
|
75
|
+
```
|
|
76
|
+
- ```python
|
|
77
|
+
def python_todos(code_text: str, todo_regex: str = 'TODO:.*') -> List[str]:
|
|
78
|
+
"""Return all todos in the given code_text that match the given todo_regex."""
|
|
79
|
+
```
|
|
80
|
+
- ```python
|
|
81
|
+
def python_make_pythonic(name: str) -> str:
|
|
82
|
+
"""Make the name pythonic.
|
|
83
|
+
|
|
84
|
+
(e.g. 'fooBar' => 'foo_bar', 'foo-bar' => 'foo_bar', 'foo bar' => 'foo_bar', 'Foo Bar' => 'foo_bar')."""
|
|
85
|
+
```
|
|
86
|
+
- ```python
|
|
87
|
+
def python_namespace_has_argument(namespace: argparse.Namespace, argument_name: str) -> bool:
|
|
88
|
+
"""."""
|
|
89
|
+
```
|
|
90
|
+
- ```python
|
|
91
|
+
def python_traceback_prettify(traceback: str) -> str:
|
|
92
|
+
"""Return a string with the given traceback pretty-printed."""
|
|
93
|
+
```
|
|
94
|
+
- ```python
|
|
95
|
+
def python_traceback_pretty_print(traceback: str) -> None:
|
|
96
|
+
"""Return a string with the given traceback pretty-printed."""
|
|
97
|
+
```
|
|
98
|
+
- ```python
|
|
99
|
+
def python_clean(code_text: str) -> str:
|
|
100
|
+
"""Clean python code as it is often found in documentation and snippets."""
|
|
101
|
+
```
|
|
102
|
+
- ```python
|
|
103
|
+
def python_function_blocks(
|
|
104
|
+
code_text: str, *, ignore_private_functions: bool = False, ignore_nested_functions: bool = False
|
|
105
|
+
) -> List[str]:
|
|
106
|
+
"""Find the code (as a string) for every function in the given code_text."""
|
|
107
|
+
```
|
|
108
|
+
- ```python
|
|
109
|
+
def python_line_count(python_code: str, *, ignore_empty_lines: bool = True) -> int:
|
|
110
|
+
"""Return the number of lines in the given function_text."""
|
|
111
|
+
```
|
|
112
|
+
- ```python
|
|
113
|
+
def python_function_lengths(code_text: str) -> List[int]:
|
|
114
|
+
"""Find the lengths of each function in the given code_text."""
|
|
115
|
+
```
|
|
116
|
+
- ```python
|
|
117
|
+
def python_version() -> str:
|
|
118
|
+
"""Return the python version of the current environment."""
|
|
119
|
+
```
|
|
120
|
+
- ```python
|
|
121
|
+
def python_is_version_2() -> bool:
|
|
122
|
+
"""Return whether or not the python version of the current environment is v2.x."""
|
|
123
|
+
```
|
|
124
|
+
- ```python
|
|
125
|
+
def python_is_version_3() -> bool:
|
|
126
|
+
"""Return whether or not the python version of the current environment is v3.x."""
|
|
127
|
+
```
|
|
128
|
+
- ```python
|
|
129
|
+
def python_files_using_function(function_name: str, search_path: str) -> List[str]:
|
|
130
|
+
"""Find where the given function is used in the given search path."""
|
|
131
|
+
```
|
|
132
|
+
- ```python
|
|
133
|
+
def python_keywords() -> List[str]:
|
|
134
|
+
"""Get a list of the python keywords."""
|
|
135
|
+
```
|
|
136
|
+
- ```python
|
|
137
|
+
def python_object_properties_enumerate(
|
|
138
|
+
python_object: Any, *, run_methods: bool = True, internal_properties: bool = True
|
|
139
|
+
) -> None:
|
|
140
|
+
"""Enumerate and print out the properties of the given object."""
|
|
141
|
+
```
|
|
142
|
+
- ```python
|
|
143
|
+
def python_copy_deep(python_object: Any) -> Any:
|
|
144
|
+
"""Return a deep (complete, recursive) copy of the given python object."""
|
|
145
|
+
```
|
|
146
|
+
- ```python
|
|
147
|
+
def python_copy_shallow(python_object: Any) -> Any:
|
|
148
|
+
"""Return shallow copy of the given python object."""
|
|
149
|
+
```
|
|
150
|
+
- ```python
|
|
151
|
+
def python_file_names(path: str, *, exclude_tests: bool = False) -> List[str]:
|
|
152
|
+
"""Find all python files in the given directory."""
|
|
153
|
+
```
|
|
154
|
+
- ```python
|
|
155
|
+
def python_fstrings(code_text: str, *, include_braces: bool = False) -> Iterator[str]:
|
|
156
|
+
"""Find all of the python formatted string literals in the given text. See https://realpython.com/python-f-strings/ for more details about f-strings."""
|
|
157
|
+
```
|
|
158
|
+
- ```python
|
|
159
|
+
def python_code_details(code_text: str):
|
|
160
|
+
"""Get details about the given code_text. This is a wrapper for `dis.code_info`"""
|
|
161
|
+
```
|
|
162
|
+
- ```python
|
|
163
|
+
def python_disassemble(code_text: str):
|
|
164
|
+
"""Disassemble the python code_text. This is a wrapper for `dis.dis`"""
|
|
165
|
+
```
|
|
166
|
+
- ```python
|
|
167
|
+
def python_stack_local_data():
|
|
168
|
+
"""Get local data in the current python environment."""
|
|
169
|
+
```
|
|
170
|
+
- ```python
|
|
171
|
+
def python_object_doc_string(python_object: Any) -> Union[str, None]:
|
|
172
|
+
"""Get the doc string for the given python object (e.g. module, function, or class)."""
|
|
173
|
+
```
|
|
174
|
+
- ```python
|
|
175
|
+
def python_object_source_file(python_object: Any) -> str:
|
|
176
|
+
"""Get the source file for the given python object (e.g. module, function, or class)."""
|
|
177
|
+
```
|
|
178
|
+
- ```python
|
|
179
|
+
def python_object_module(python_object: Any) -> str:
|
|
180
|
+
"""Get the module for the given python object (e.g. function or class)."""
|
|
181
|
+
```
|
|
182
|
+
- ```python
|
|
183
|
+
def python_object_source_code(python_object: Any) -> str:
|
|
184
|
+
"""Get the source code for the given python object (e.g. module, function, or class)."""
|
|
185
|
+
```
|
|
186
|
+
- ```python
|
|
187
|
+
def python_object_signature(python_object: Any) -> str:
|
|
188
|
+
"""Get the argument signature for the given python object (e.g. module, function, or class)."""
|
|
189
|
+
```
|
|
190
|
+
- ```python
|
|
191
|
+
def python_sort_type_list_by_name(python_type_list: List[type], **kwargs) -> List[type]:
|
|
192
|
+
"""."""
|
|
193
|
+
```
|
|
194
|
+
- ```python
|
|
195
|
+
def python_type_name(python_type: type) -> str:
|
|
196
|
+
"""Return the common name of the given type."""
|
|
197
|
+
```
|
|
198
|
+
- ```python
|
|
199
|
+
def python_object_type_to_word(python_object: Any) -> str:
|
|
200
|
+
"""Convert the given python type to a string."""
|
|
201
|
+
```
|
|
202
|
+
- ```python
|
|
203
|
+
def python_ast_raise_name(node: ast.Raise) -> Optional[str]:
|
|
204
|
+
"""Get the name of the exception raise by the given ast.Raise object."""
|
|
205
|
+
```
|
|
206
|
+
- ```python
|
|
207
|
+
def python_ast_exception_handler_exceptions_handled(handler: ast.ExceptHandler) -> Optional[Iterable[str]]:
|
|
208
|
+
"""Return all of the exceptions handled by the given exception handler."""
|
|
209
|
+
```
|
|
210
|
+
- ```python
|
|
211
|
+
def python_ast_exception_handler_exceptions_raised(handler: ast.ExceptHandler) -> Optional[Iterable[str]]:
|
|
212
|
+
"""Return the exception raised by the given exception handler."""
|
|
213
|
+
```
|
|
214
|
+
- ```python
|
|
215
|
+
def python_exceptions_handled(code_text: str) -> Iterable[str]:
|
|
216
|
+
"""Return a list of all exceptions handled in the given code."""
|
|
217
|
+
```
|
|
218
|
+
- ```python
|
|
219
|
+
def python_exceptions_raised(code_text: str) -> Iterable[str]:
|
|
220
|
+
"""Return a list of all exceptions raised in the given code."""
|
|
221
|
+
```
|
|
222
|
+
- ```python
|
|
223
|
+
def python_functions_as_import_string(code_text: str, module_name: str) -> str:
|
|
224
|
+
"""."""
|
|
225
|
+
```
|
|
226
|
+
- ```python
|
|
227
|
+
def python_ast_object_line_number(ast_object: object) -> Optional[int]:
|
|
228
|
+
"""."""
|
|
229
|
+
```
|
|
230
|
+
- ```python
|
|
231
|
+
def python_ast_object_line_numbers(ast_object: object) -> Tuple[int, int]:
|
|
232
|
+
"""."""
|
|
233
|
+
```
|
|
234
|
+
- ```python
|
|
235
|
+
def python_ast_objects_of_type(
|
|
236
|
+
code_text_or_ast_object: Union[str, object], ast_type: type, *, recursive_search: bool = True
|
|
237
|
+
) -> Iterable[object]:
|
|
238
|
+
"""Return all of the ast objects of the given ast_type in the code_text_or_ast_object."""
|
|
239
|
+
```
|
|
240
|
+
- ```python
|
|
241
|
+
def python_ast_objects_not_of_type(code_text_or_ast_object: Union[str, object], ast_type: type) -> Iterable[object]:
|
|
242
|
+
"""Return all of the ast objects which are not of the given ast_type in the code_text_or_ast_object."""
|
|
243
|
+
```
|
|
244
|
+
- ```python
|
|
245
|
+
def python_ast_parse(code_text: str) -> ast.Module:
|
|
246
|
+
"""."""
|
|
247
|
+
```
|
|
248
|
+
- ```python
|
|
249
|
+
def python_ast_function_defs(code_text: str, recursive_search: bool = True) -> Iterable[ast.FunctionDef]:
|
|
250
|
+
"""."""
|
|
251
|
+
```
|
|
252
|
+
- ```python
|
|
253
|
+
def python_function_arguments(function_text: str) -> List[ast.arg]:
|
|
254
|
+
"""."""
|
|
255
|
+
```
|
|
256
|
+
- ```python
|
|
257
|
+
def python_function_argument_names(function_text: str) -> Iterable[str]:
|
|
258
|
+
"""."""
|
|
259
|
+
```
|
|
260
|
+
- ```python
|
|
261
|
+
def python_function_argument_defaults(function_text: str) -> List[str]:
|
|
262
|
+
"""."""
|
|
263
|
+
```
|
|
264
|
+
- ```python
|
|
265
|
+
def python_function_argument_annotations(function_text: str) -> List[str]:
|
|
266
|
+
"""."""
|
|
267
|
+
```
|
|
268
|
+
- ```python
|
|
269
|
+
def python_function_names(
|
|
270
|
+
code_text: str, *, ignore_private_functions: bool = False, ignore_nested_functions: bool = False
|
|
271
|
+
) -> List[str]:
|
|
272
|
+
"""."""
|
|
273
|
+
```
|
|
274
|
+
- ```python
|
|
275
|
+
def python_function_docstrings(
|
|
276
|
+
code_text: str, *, ignore_private_functions: bool = False, ignore_nested_functions: bool = False
|
|
277
|
+
) -> List[str]:
|
|
278
|
+
"""Get docstrings for all of the functions in the given text."""
|
|
279
|
+
```
|
|
280
|
+
- ```python
|
|
281
|
+
def python_variable_names(code_text: str) -> List[str]:
|
|
282
|
+
"""Get all of the variables names in the code_text."""
|
|
283
|
+
```
|
|
284
|
+
- ```python
|
|
285
|
+
def python_constants(code_text: str) -> List[str]:
|
|
286
|
+
"""Get all constants in the code_text."""
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Development
|
|
290
|
+
|
|
291
|
+
👋 If you want to get involved in this project, we have some short, helpful guides below:
|
|
292
|
+
|
|
293
|
+
- [contribute to this project 🥇][contributing]
|
|
294
|
+
- [test it 🧪][local-dev]
|
|
295
|
+
- [lint it 🧹][local-dev]
|
|
296
|
+
- [explore it 🔭][local-dev]
|
|
297
|
+
|
|
298
|
+
If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.
|
|
299
|
+
|
|
300
|
+
## Credits
|
|
301
|
+
|
|
302
|
+
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and Floyd Hightower's [Python project template](https://github.com/fhightower-templates/python-project-template).
|
|
303
|
+
|
|
304
|
+
[contributing]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#contributing-a-pr-
|
|
305
|
+
[local-dev]: https://github.com/democritus-project/.github/blob/main/CONTRIBUTING.md#local-development-
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/democritus-project/d8s-python/actions)
|
|
6
6
|
[](https://codecov.io/gh/democritus-project/d8s-python)
|
|
7
7
|
[](https://semver.org/spec/v2.0.0.html)
|
|
8
|
-
[](https://github.com/astral-sh/ruff)
|
|
9
9
|
[](https://choosealicense.com/licenses/lgpl-3.0/)
|
|
10
10
|
|
|
11
11
|
Democritus functions<sup>[1]</sup> for working with Python data (code and ASTs).
|