Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install just
uses: extractions/setup-just@v1
uses: extractions/setup-just@v3
- name: Install dependencies
run: |
just install
- name: Lint with flake8, mypy, pylint, isort and black
- name: Lint with mypy, pylint, and ruff
run: |
just lint
- name: Test with pytest
Expand Down
8 changes: 0 additions & 8 deletions .isort.cfg

This file was deleted.

30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ Read [here](https://www.butterfly.com.au/blog/website-development/clean-high-qua
- can catch even duplicate code in different files! 🙌
- helps you to start refactoring before your code becomes too messy

- [Flake8](http://flake8.readthedocs.io)
- helps to write standard, clean, and documented code
- wraps pep8, pyflakes, McCabe Complexity analysis
- supports plugins

- [Isort](https://pycqa.github.io/isort/)
- Keep imports sorted alphabetically and grouped (standard, third party, local)
- [Ruff](https://github.com/astral-sh/ruff): an extremely fast Python linter and code formatter, written in Rust. Ruff can be used to replace Flake8 (plus dozens of plugins), Black, isort, pydocstyle, pyupgrade, autoflake, and more, all while executing tens or hundreds of times faster than any individual tool.
- ⚡️ 10-100x faster than existing linters (like Flake8) and formatters (like Black)
- 🐍 Installable via pip
- 🛠️ pyproject.toml support
- 🤝 Python 3.13 compatibility
- ⚖️ Drop-in parity with Flake8, isort, and Black
- 📦 Built-in caching, to avoid re-analyzing unchanged files
- 🔧 Fix support, for automatic error correction (e.g., automatically remove unused imports)
- 📏 Over 800 built-in rules, with native re-implementations of popular Flake8 plugins, like - flake8-bugbear
- ⌨️ First-party editor integrations for VS Code and more
- 🌎 Monorepo-friendly, with hierarchical and cascading configuration

- [MkDocs](https://www.mkdocs.org/)
- generates html documentation
Expand All @@ -57,13 +61,6 @@ Read [here](https://www.butterfly.com.au/blog/website-development/clean-high-qua
- `pip-sync` installs from requirements.txt
- You can also have dev-requirements if you want

- [Poetry](https://python-poetry.org/)
- Poetry comes with all the tools you might need to manage your projects in a deterministic way
- Dependency resolver, isolation, cli
- Check the state of your dependencies
- Easily build and package your projects with a single command
- Make your work known by publishing it to PyPI

- [just](https://github.com/casey/just)
- rules them all together in your workflow
- `just check` to make sure everything is OK
Expand All @@ -74,7 +71,6 @@ Read [here](https://www.butterfly.com.au/blog/website-development/clean-high-qua

- [Git](https://git-scm.com)
- [Python3](https://docs.python.org/3/)
- [Poetry](https://python-poetry.org/)
- [just](https://github.com/casey/just)

## Usage
Expand Down Expand Up @@ -103,9 +99,9 @@ checks, pedantic):

just install-hooks

To install hook to black-format code before commit:
To install hook to check code when commit:

just black-hook
just ruff-hook

### Badges

Expand Down
39 changes: 14 additions & 25 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ install-hooks:
# install pre-push hook
echo "just test" > .git/hooks/pre-push&&chmod +x .git/hooks/pre-push

# install hook to black code before commit
black-hook:
# ensures that all your commits contain Python code formatted according to Black’s rules.
cp pre-commit-black .git/hooks/pre-commit&&chmod +x .git/hooks/pre-commit
# install hook to check code before commit
ruff-hook:
# ensures that all your commits contain Python code formatted according to ruff’s rules.
cp pre-commit-ruff .git/hooks/pre-commit&&chmod +x .git/hooks/pre-commit

# bootstrap your virtualenv (deprecated)
setenv VIRTUALENV:
Expand All @@ -135,35 +135,24 @@ setenv VIRTUALENV:
@_mypy:
mypy --ignore-missing-imports src

@_flake8:
flake8 .

@_pylint:
pylint $(git ls-files '*.py') --ignore conf.py

@_isort:
isort --check-only --recursive --quiet . || just _fail "Fix imports by calling \'just fix\'."

@_black:
black --check -q . || just _fail "Fix code formatting by calling \'just fix\'."
@_ruff:
ruff check -q $(git ls-files '*.py')

# statically check the codebase (mypy, flake8, pylint, isort)
# statically check the codebase (mypy, pylint, ruff)
@lint:
just _mypy
echo "mypy : OK "
just _flake8
echo "flake8: OK ✅✅"
echo "mypy : OK ☑️"
just _ruff
echo "ruff : OK ⚡️⚡️"
just _pylint
echo "pylint: OK ✅✅✅"
just _isort
echo "isort : OK ✅✅✅ 🍰"
just _black
echo "black : OK ✅✅✅ 🍒"
echo "pylint: OK ☑️☑️☑️"

# auto fix imports and pep8 coding style
# auto fix imports and pep8 coding style (via ruff)
@fix:
isort .
black .
ruff format .
# Re-check code quality
just lint

Expand All @@ -174,7 +163,7 @@ setenv VIRTUALENV:
# run tests only (with no coverage and no lint)
@test:
pytest
echo "Tests: OK ✅✅✅"
echo "Tests: OK ✅✅✅"

# run tests with coverage.py, create html report and open it
@cov:
Expand Down
10 changes: 0 additions & 10 deletions pre-commit-black

This file was deleted.

10 changes: 10 additions & 0 deletions pre-commit-ruff
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Run Ruff check on all Python files
files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
if [ -n "$files" ]; then
echo "Running Ruff check on Python files..."
ruff check $files
# Run the Ruff formatter on the given files or directories
ruff format --check $files
fi
26 changes: 17 additions & 9 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ ignore-paths=
# Emacs file locks
ignore-patterns=^\.#

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
# List of module names for which member attributes should not be checked and
# will not be imported (useful for modules/projects where namespaces are
# manipulated during runtime and thus existing member attributes cannot be
# deduced by static analysis). It supports qualified module names, as well as
# Unix pattern matching.
ignored-modules=

# Python code to execute, usually for sys.path manipulation such as
Expand All @@ -86,6 +87,10 @@ load-plugins=
# Pickle collected data for later comparisons.
persistent=yes

# Resolve imports to .pyi stubs if available. May reduce no-member messages and
# increase not-an-iterable messages.
prefer-stubs=no

# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.11
Expand Down Expand Up @@ -302,6 +307,9 @@ max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7

# Maximum number of positional arguments for function / method.
max-positional-arguments=5

# Maximum number of public methods for a class (see R0904).
max-public-methods=20

Expand Down Expand Up @@ -487,10 +495,10 @@ evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor
# used to format the message information. See doc for all details.
msg-template=

# Set the output format. Available formats are: text, parseable, colorized,
# json2 (improved json format), json (old json format) and msvs (visual
# studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
# Set the output format. Available formats are: 'text', 'parseable',
# 'colorized', 'json2' (improved json format), 'json' (old json format), msvs
# (visual studio) and 'github' (GitHub actions). You can also give a reporter
# class, e.g. mypackage.mymodule.MyReporterClass.
#output-format=

# Tells whether to display a full report or only the messages.
Expand Down Expand Up @@ -592,7 +600,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local,argparse.Namespace
# of finding the hint is based on edit distance.
missing-member-hint=yes

# The minimum edit distance a name should have in order to be considered a
# The maximum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1

Expand Down
4 changes: 1 addition & 3 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ pytest-cov
coverage
mypy
pylint
flake8
isort
black
ruff

# Documentation
mkdocs
Expand Down
Loading