Skip to content

Commit ee7be55

Browse files
committed
chore(pre-commit): restrict bandit to package and exclude tests
1 parent ad0f24b commit ee7be55

25 files changed

+1370
-535
lines changed

.pre-commit-config.yaml

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,105 @@
1+
# Pre-commit hooks for min-ratio-cycle
2+
# Tip: keep hook versions aligned with your pyproject/dev-deps where applicable.
3+
# Install & run:
4+
# poetry run pre-commit install
5+
# poetry run pre-commit run --all-files
6+
7+
ci:
8+
autofix_prs: true
9+
autoupdate_schedule: monthly
10+
11+
minimum_pre_commit_version: "3.5.0"
12+
default_stages: [commit]
13+
14+
default_language_version:
15+
python: python3
16+
17+
# Global excludes (applies to all hooks)
18+
exclude: |
19+
(?x)(
20+
^docs/_build/|
21+
^build/|
22+
^dist/|
23+
^\.venv/|
24+
^\.mypy_cache/|
25+
^\.pytest_cache/|
26+
^\.ruff_cache/|
27+
^\.git/|
28+
^poetry\.lock$|
29+
\.ipynb$
30+
)
31+
132
repos:
233
- repo: https://github.com/pre-commit/pre-commit-hooks
334
rev: v4.6.0
435
hooks:
5-
- id: trailing-whitespace
6-
- id: end-of-file-fixer
736
- id: check-yaml
37+
- id: check-json
38+
- id: end-of-file-fixer
39+
- id: trailing-whitespace
40+
- id: mixed-line-ending
41+
args: [--fix=lf]
42+
- id: check-merge-conflict
43+
- id: detect-private-key
844
- id: check-added-large-files
45+
args: ["--maxkb=500"]
46+
947
- repo: https://github.com/psf/black
10-
rev: 23.9.1
48+
# Pin to match your dev dependency (e.g., 24.3.0)
49+
rev: 24.3.0
1150
hooks:
1251
- id: black
13-
- repo: https://github.com/PyCQA/isort
14-
rev: 5.12.0
52+
args: ["--line-length=88"]
53+
54+
- repo: https://github.com/charliermarsh/ruff-pre-commit
55+
rev: v0.6.9
56+
hooks:
57+
- id: ruff
58+
# Ruff handles lint + import sorting (I001); keep black for formatting
59+
args: ["--fix"]
60+
stages: [manual]
61+
62+
- repo: https://github.com/pycqa/isort
63+
rev: 5.13.2
1564
hooks:
1665
- id: isort
66+
# If you rely on Ruff for import sorting, you can remove isort
67+
args: ["--profile=black", "--line-length=88"]
68+
69+
- repo: https://github.com/asottile/pyupgrade
70+
rev: v3.16.0
71+
hooks:
72+
- id: pyupgrade
73+
args: ["--py310-plus"]
74+
75+
- repo: https://github.com/pre-commit/mirrors-mypy
76+
rev: v1.10.0
77+
hooks:
78+
- id: mypy
79+
stages: [manual]
80+
additional_dependencies:
81+
- types-setuptools
82+
args: ["--strict"]
83+
84+
85+
- repo: https://github.com/PyCQA/docformatter
86+
rev: v1.7.5
87+
hooks:
88+
- id: docformatter
89+
args: ["--in-place", "--pre-summary-newline", "--make-summary-multi-line"]
90+
91+
- repo: https://github.com/codespell-project/codespell
92+
rev: v2.3.0
93+
hooks:
94+
- id: codespell
95+
args: ["-L", "datas,nin", "--skip", "poetry.lock,docs/_build,*.svg"]
96+
1797
- repo: https://github.com/PyCQA/bandit
18-
rev: 1.7.5
98+
rev: 1.7.9
1999
hooks:
20100
- id: bandit
21-
args: ["-ll"]
22-
files: ^min_ratio_cycle/
101+
name: bandit (lib only)
102+
stages: [manual]
103+
pass_filenames: false
104+
args: ["-r", "min_ratio_cycle", "-x", "tests", "-ll", "-ii"]
105+
additional_dependencies: ["bandit[toml]"]

CODE_OF_CONDUCT.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Code of Conduct
2+
3+
We are committed to providing a friendly, safe, and welcoming environment for all contributors and users of **min-ratio-cycle**.
4+
5+
This project follows the spirit of the **Contributor Covenant v2.1**.
6+
7+
---
8+
9+
## Our Pledge
10+
11+
We as members, contributors, and leaders pledge to make participation in our community a harassment‑free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio‑economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
12+
13+
## Our Standards
14+
15+
Examples of behavior that contributes to a positive environment include:
16+
17+
* Demonstrating empathy and kindness toward other people
18+
* Being respectful of differing opinions, viewpoints, and experiences
19+
* Giving and gracefully accepting constructive feedback
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior include:
24+
25+
* The use of sexualized language or imagery, and sexual attention or advances
26+
* Trolling, insulting or derogatory comments, and personal or political attacks
27+
* Public or private harassment
28+
* Publishing others’ private information without explicit permission
29+
* Other conduct which could reasonably be considered inappropriate in a professional setting
30+
31+
## Scope
32+
33+
This Code of Conduct applies within all project spaces and also applies when an individual is officially representing the project in public spaces.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project maintainers at **[[email protected]](mailto:[email protected])**. All complaints will be reviewed and investigated promptly and fairly.
38+
39+
Project maintainers are obligated to respect the privacy and security of the reporter of any incident.
40+
41+
## Enforcement Guidelines
42+
43+
Community leaders will follow these guidelines to determine the consequences for any action they deem in violation of this Code of Conduct:
44+
45+
1. **Correction** – Private, written warning, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate.
46+
2. **Warning** – A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time.
47+
3. **Temporary Ban** – A temporary ban from any sort of interaction or public communication with the community.
48+
4. **Permanent Ban** – A permanent ban from any sort of public interaction within the community.
49+
50+
## Attribution
51+
52+
This Code of Conduct is adapted from the **Contributor Covenant**, version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code\_of\_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html)
53+
54+
Community Impact Guidelines were inspired by the **Mozilla Community Participation Guidelines**.
55+
56+
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).

CONTRIBUTING.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contributing to min-ratio-cycle
2+
3+
Thanks for your interest in improving **min-ratio-cycle**! This guide explains how to set up your environment, the project conventions, and the pull‑request process.
4+
5+
--------------------------------------------------------------------------------
6+
7+
## Ground rules
8+
9+
- Be respectful and follow our [Code of Conduct](./CODE_OF_CONDUCT.md).
10+
- Favor small, focused PRs with clear motivation and tests.
11+
- Use **Conventional Commits**: `feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `perf:`, `build:`, `chore:`.
12+
- Public API is documented in the README under **API surface (stable)**; changing it requires a discussion/issue first.
13+
14+
--------------------------------------------------------------------------------
15+
16+
## Environment setup
17+
18+
1. **Install Poetry** (<https://python-poetry.org/docs/#installation>)
19+
20+
```bash
21+
poetry --version
22+
```
23+
24+
1. **Install dependencies** and enable hooks
25+
26+
```bash
27+
poetry install
28+
poetry run pre-commit install
29+
```
30+
31+
1. **Run the test suite & quality checks**
32+
33+
```bash
34+
poetry run pytest --cov=min_ratio_cycle
35+
poetry run mypy min_ratio_cycle
36+
poetry run black . && poetry run isort .
37+
poetry run flake8 .
38+
poetry run bandit -r min_ratio_cycle
39+
```
40+
41+
> Tip: for consistent benchmarking, pin BLAS threads: `OMP_NUM_THREADS=1 MKL_NUM_THREADS=1`.
42+
43+
--------------------------------------------------------------------------------
44+
45+
## Development workflow
46+
47+
- **Branch** from `main` using a descriptive name, e.g., `feat/exact-mode-fastpath` or `fix/negcycle-offbyone`.
48+
- **Write tests** alongside code (`tests/`), prefer small unit tests; add property tests when relevant.
49+
- **Document** new APIs/behaviors in docstrings and the README. Keep docs building (`sphinx-build`).
50+
- **Type hints** are required for new/changed code. We ship a `py.typed` marker for downstream tooling.
51+
- **Performance**: if changing core loops/oracles, add a benchmark note or evidence.
52+
53+
--------------------------------------------------------------------------------
54+
55+
## Pull request checklist
56+
57+
- [ ] Tests added/updated and passing locally (`pytest`).
58+
- [ ] Type checks pass (`mypy`).
59+
- [ ] Style/lint pass (`black`, `isort`, `flake8`).
60+
- [ ] Security scan pass (`bandit`).
61+
- [ ] Docs updated (README / Sphinx).
62+
- [ ] Changelog entry added if user‑visible change.
63+
- [ ] CI is green.
64+
65+
--------------------------------------------------------------------------------
66+
67+
## Reporting bugs / proposing features
68+
69+
- **Bugs**: open an issue with a minimal reproducible example and environment details.
70+
- **Features**: start a discussion/issue explaining motivation, alternatives, and expected API.
71+
72+
--------------------------------------------------------------------------------
73+
74+
## Release process (maintainers)
75+
76+
- Use semantic versioning. Tag releases on `main` (e.g., `v0.1.0`).
77+
- Publish to PyPI via GitHub Actions workflow (builds must be green).
78+
79+
--------------------------------------------------------------------------------
80+
81+
## Contact
82+
83+
For security issues or CoC enforcement, write to **<[email protected]>**.

0 commit comments

Comments
 (0)