Skip to content

Commit 6cdf41b

Browse files
Improved typing (#3)
* feat: enhance package with improved typing, documentation, and automation * feat: enhance package with improved typing, documentation, and automation * feat: enhance package with improved typing, documentation, and automation * feat: enhance package with improved typing, documentation, and automation * feat: enhance package with improved typing, documentation, and automation * feat: enhance package with improved typing, documentation, and automation * feat: enhance package with improved typing, documentation, and automation * feat: readthedocs documentation * Update scripts/check_docstrings_coverage.py Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 8847f1e commit 6cdf41b

Some content is hidden

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

41 files changed

+4264
-112
lines changed

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
charset = utf-8
12+
13+
# Python files
14+
[*.py]
15+
indent_style = space
16+
indent_size = 4
17+
max_line_length = 100
18+
19+
# YAML files
20+
[*.{yml,yaml}]
21+
indent_style = space
22+
indent_size = 2
23+
24+
# JSON files
25+
[*.json]
26+
indent_style = space
27+
indent_size = 2
28+
29+
# Markdown files
30+
[*.md]
31+
trim_trailing_whitespace = false
32+
33+
# Makefile
34+
[Makefile]
35+
indent_style = tab

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,49 @@ labels: bug
66
assignees: ''
77
---
88

9-
**Describe the bug** A clear and concise description of what the bug is.
9+
# Describe the bug
1010

11-
**To Reproduce** Steps to reproduce the behavior:
11+
A clear and concise description of what the bug is.
12+
13+
# To Reproduce
14+
15+
Steps to reproduce the behavior:
1216

1317
1. Install package '...'
1418
2. Run code '...'
1519
3. See error
1620

17-
**Expected behavior** A clear and concise description of what you expected to happen.
21+
# Expected behavior
22+
23+
A clear and concise description of what you expected to happen.
1824

19-
**Environment:**
25+
# Actual behavior
26+
27+
A clear description of what actually happened.
28+
29+
# Environment:
2030

2131
- OS: [e.g. Ubuntu 22.04, Windows 11]
2232
- Python version: [e.g. 3.10.8]
2333
- Package version: [e.g. 0.1.1]
34+
- Installation method: [e.g. pip, poetry, from source]
35+
36+
# Error message/logs
37+
38+
```
39+
Paste any error messages or logs here
40+
```
41+
42+
# Possible Solution
43+
44+
If you have suggestions on a fix for the bug, please describe it here.
45+
46+
# Additional context
47+
48+
Add any other context about the problem here.
49+
50+
# Checklist
2451

25-
**Additional context** Add any other context about the problem here.
52+
- [ ] I have checked that this issue has not already been reported
53+
- [ ] I have provided all the information needed to understand the bug
54+
- [ ] I have simplified the reproduction steps as much as possible

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,43 @@
22
name: Feature request
33
about: Suggest an idea for this project
44
title: '[FEATURE] '
5-
labels: 'enhancement'
5+
labels: enhancement
66
assignees: ''
7-
87
---
98

10-
**Is your feature request related to a problem? Please describe.**
9+
# Is your feature request related to a problem? Please describe.
10+
1111
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
1212

13-
**Describe the solution you'd like**
13+
# Describe the solution you'd like
14+
1415
A clear and concise description of what you want to happen.
1516

16-
**Describe alternatives you've considered**
17+
# Describe alternatives you've considered
18+
1719
A clear and concise description of any alternative solutions or features you've considered.
1820

19-
**Additional context**
21+
# User experience / example code
22+
23+
How would users interact with this feature? If applicable, provide example code or CLI commands showing how this feature would be used.
24+
25+
```python
26+
# Example code demonstrating how the feature would be used
27+
from my_python_package import new_feature
28+
29+
new_feature.do_something()
30+
```
31+
32+
# Benefits and potential drawbacks
33+
34+
What are the benefits of implementing this feature? Are there any potential drawbacks or challenges you foresee?
35+
36+
# Additional context
37+
2038
Add any other context or screenshots about the feature request here.
39+
40+
# Checklist
41+
42+
- [ ] I have checked that this feature has not already been requested
43+
- [ ] I have considered the scope of this feature and how it fits with the project's goals
44+
- [ ] I have provided clear examples of how the feature would be used

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
# Description
1+
# Pull Request
22

3-
<!-- Describe the changes in this PR -->
3+
## Description
4+
<!-- Provide a detailed description of the changes in this PR -->
45

5-
# Type of change
6+
## Related Issues
7+
<!-- List any related issues that are addressed by this PR -->
8+
<!-- Use the syntax "Fixes #123" or "Resolves #123" to automatically close the issue when the PR is merged -->
9+
10+
## Type of change
11+
<!-- Please check all that apply by replacing [ ] with [x] -->
612

713
- [ ] Bug fix (non-breaking change which fixes an issue)
814
- [ ] New feature (non-breaking change which adds functionality)
915
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
1016
- [ ] Documentation update
17+
- [ ] Performance improvement
18+
- [ ] Code refactoring (no functional changes)
19+
- [ ] Test additions or improvements
20+
- [ ] CI/CD or build system changes
21+
22+
## How Has This Been Tested?
23+
<!-- Please describe the tests that you ran to verify your changes -->
24+
<!-- Include details of your testing environment, tests ran, and the outcomes -->
1125

12-
# Checklist
26+
## Checklist
27+
<!-- Please check all that apply by replacing [ ] with [x] -->
1328

1429
- [ ] My code follows the style guidelines of this project
1530
- [ ] I have performed a self-review of my own code
@@ -18,3 +33,12 @@
1833
- [ ] My changes generate no new warnings
1934
- [ ] I have added tests that prove my fix is effective or that my feature works
2035
- [ ] New and existing unit tests pass locally with my changes
36+
- [ ] Any dependent changes have been merged and published in downstream modules
37+
- [ ] I have updated the version number as appropriate (for feature/breaking changes)
38+
- [ ] I have added a note to CHANGELOG.md if appropriate
39+
40+
## Screenshots (if applicable)
41+
<!-- Add screenshots or GIFs to demonstrate the changes if applicable -->
42+
43+
## Additional context
44+
<!-- Add any other context about the PR here -->

.github/workflows/code-coverage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
branches: [ "main" ]
88
workflow_dispatch:
99

10+
# Add permissions block here
11+
permissions:
12+
contents: write # Needed to update the README.md file
13+
1014
jobs:
1115
coverage:
1216
runs-on: ubuntu-latest

.github/workflows/dependabot.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Dependabot configuration file
2+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
# Enable version updates for Python
7+
- package-ecosystem: "pip"
8+
# Look for requirements files in the root directory
9+
directory: "/"
10+
# Check for updates once a week (Monday)
11+
schedule:
12+
interval: "weekly"
13+
day: "monday"
14+
# Group dependencies to consolidate PRs
15+
groups:
16+
dev-dependencies:
17+
patterns:
18+
- "black"
19+
- "isort"
20+
- "ruff"
21+
- "mypy"
22+
- "pytest*"
23+
- "bandit"
24+
- "pre-commit"
25+
production-dependencies:
26+
patterns:
27+
- "*"
28+
exclude-patterns:
29+
- "black"
30+
- "isort"
31+
- "ruff"
32+
- "mypy"
33+
- "pytest*"
34+
- "bandit"
35+
- "pre-commit"
36+
# Maximum number of open PRs
37+
open-pull-requests-limit: 10
38+
# Prefix PR titles
39+
commit-message:
40+
prefix: "deps"
41+
include: "scope"
42+
# Add labels to PRs
43+
labels:
44+
- "dependencies"
45+
- "automerge"
46+
# Allow automatic merging
47+
reviewers:
48+
- "DiogoRibeiro7"
49+
assignees:
50+
- "DiogoRibeiro7"
51+
52+
# Enable version updates for GitHub Actions
53+
- package-ecosystem: "github-actions"
54+
directory: "/"
55+
schedule:
56+
interval: "weekly"
57+
day: "monday"
58+
open-pull-requests-limit: 10
59+
commit-message:
60+
prefix: "ci"
61+
include: "scope"
62+
labels:
63+
- "dependencies"
64+
- "github_actions"
65+
- "automerge"
66+
reviewers:
67+
- "DiogoRibeiro7"
68+
assignees:
69+
- "DiogoRibeiro7"
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Docstring Coverage
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
docstring-coverage:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
26+
- name: Check docstring coverage
27+
run: |
28+
python scripts/check_docstring_coverage.py --min-coverage 80
29+
30+
- name: Generate docstring coverage badge
31+
run: |
32+
python -c "
33+
import re
34+
import subprocess
35+
import json
36+
37+
# Run the docstring coverage script and capture output
38+
result = subprocess.run(
39+
['python', 'scripts/check_docstring_coverage.py', '--dir', 'src'],
40+
capture_output=True,
41+
text=True
42+
)
43+
44+
# Extract the overall coverage percentage
45+
match = re.search(r'Overall docstring coverage: (\d+\.\d+)%', result.stdout)
46+
if match:
47+
coverage = float(match.group(1))
48+
49+
# Determine badge color
50+
color = 'red'
51+
if coverage >= 90:
52+
color = 'brightgreen'
53+
elif coverage >= 80:
54+
color = 'green'
55+
elif coverage >= 70:
56+
color = 'yellowgreen'
57+
elif coverage >= 60:
58+
color = 'yellow'
59+
elif coverage >= 50:
60+
color = 'orange'
61+
62+
# Create badge URL
63+
badge_url = f'https://img.shields.io/badge/docstring%20coverage-{coverage:.1f}%25-{color}'
64+
65+
# Update README.md
66+
with open('README.md', 'r') as f:
67+
readme = f.read()
68+
69+
# Look for existing docstring coverage badge
70+
docstring_badge_pattern = r'!\[Docstring Coverage\]\(https://img\.shields\.io/badge/docstring%20coverage-[\d\.]+%25-[a-z]+\)'
71+
if re.search(docstring_badge_pattern, readme):
72+
# Replace existing badge
73+
readme = re.sub(docstring_badge_pattern, f'![Docstring Coverage]({badge_url})', readme)
74+
else:
75+
# Look for badge section to add to
76+
badge_section = re.search(r'(!\[[^\]]+\]\([^\)]+\)[ \t]*)+', readme)
77+
if badge_section:
78+
# Add to existing badges
79+
end_pos = badge_section.end()
80+
readme = readme[:end_pos] + f' ![Docstring Coverage]({badge_url})' + readme[end_pos:]
81+
else:
82+
# Add after first line
83+
first_line_end = readme.find('\\n')
84+
if first_line_end != -1:
85+
readme = readme[:first_line_end+1] + f'\\n![Docstring Coverage]({badge_url})\\n' + readme[first_line_end+1:]
86+
else:
87+
readme = readme + f'\\n\\n![Docstring Coverage]({badge_url})\\n'
88+
89+
with open('README.md', 'w') as f:
90+
f.write(readme)
91+
92+
print(f'Updated README.md with docstring coverage badge: {coverage:.1f}%')
93+
else:
94+
print('Could not extract docstring coverage percentage')
95+
"
96+
97+
- name: Commit updated README with docstring coverage badge
98+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
99+
run: |
100+
git config user.name "github-actions[bot]"
101+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
102+
git add README.md
103+
git diff --quiet && git diff --staged --quiet || (
104+
git commit -m "docs: update docstring coverage badge [skip ci]"
105+
git push
106+
)
107+
108+
permissions:
109+
contents: write

0 commit comments

Comments
 (0)