Invokes Python dev tools at once.
Project description
Invoke Lint
Invokes Python dev tools at once.
Attention
- The development status of this package is Beta now. It may not be able to keep backward compatibility. Be careful to use, especially for CI.
- Currently, each commands require to run in project home directory.
Advantage
- Covers major development tools and they are optional to install
- Quick response for developer, slow but detail for CI
- Available to place commands into your selected namespace
1. Covers major development tools and they are optional to install
You can choose which dev tool you'll install, this package doesn't force to install each of dev tools. It helps you to avoid conflicts or breaking your project's dependencies.
Supporting tools:
Linters:
Formatters:
For test and coverage:
Package build:
2. Quick response for developer, slow but detailed for CI
The commands for each kind of tasks are designed as unified into 2 main commands:
- For developer: Runs only quick responsive dev tools at once
- For CI (or final check): Runs slow but detailed responsive tools at once
3. Available to place commands into your selected namespace
This doesn't pollute your comfortable namespaces of command line tools. Thanks to Invoke, you can place commands into your selected namespace. (See: Quickstart)
Representative commands
(Note that the namespaces of following commands can be changed as you like. See: Quickstart)
inv style
Formats code by following tools at once:
inv style --check
can only check.inv style --ruff
can leave Ruff warnings.
inv lint
Runs following fast lints at once:
The format task (described later) also run before run above lints. You can skip them by --skip-format
option.
inv lint.deep
Runs following slow but detailed lints at once:
inv radon
Reports radon both code complexity and maintainability index.
inv test
Runs fast tests (which is not marked @pytest.mark.slow
) by pytest.
See:
- How to mark test functions with attributes — pytest documentation
- Working with custom markers — pytest documentation
inv test.cov
Runs all tests and report coverage by pytest and Coverage.py.
It also can dump coverage as XML or HTML format.
inv dist
Builds source and wheel packages into dist/
directory by build.
(Currently, not support in Windows)
See:
- Building and Distributing Packages with Setuptools - setuptools latest documentation
- Package Discovery and Namespace Packages - setuptools latest documentation
Quickstart
1. Install
It's better to use one of dependency management tools to resolve dependencies of many dev tools.
For example, in case when use Pipenv, Pipfile
:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
autoflake = "*"
bandit = {version = "*", markers="python_version >= '3.7'"}
black = {version = "*", markers="python_version >= '3.7'"}
build = "*"
# Hotfix for Pipenv's Bug:
# - Pipenv should prioritize more cross-platform sys_platform condition between packages when lock
# · Issue #4101 · pypa/pipenv
# https://github.com/pypa/pipenv/issues/4101
colorama = "*"
# Pipenv can't crawl coverage==3.5.3:
# - Command: "pipenv install --skip-lock" fails
# since it tries to parse legacy package metadata and raise InstallError
# · Issue #5595 · pypa/pipenv
# https://github.com/pypa/pipenv/issues/5595#issuecomment-1454769781
coverage = ">=3.5.4"
# The dlint less than 0.14.0 limits max version of flake8.
dlint = ">=0.14.0"
docformatter = {extras = ["tomli"], version = "*"}
dodgy = "*"
# Since Pipenv can't lock for too much combinations to attempt lock:
# pip._vendor.resolvelib.resolvers.ResolutionTooDeep: 2000000
# The hacking depends flake8 ~=6.1.0 or ~=5.0.1 or ~=4.0.1.
flake8 = {version = "!=6.0.0,!=5.0.0,>=4.0.1", markers="python_version >= '3.6'"}
# To use flake8 --radon-show-closures
flake8-polyfill = "*"
# Latest hacking depends on legacy version of flake8, and legacy hacking doesn't narrow flake8 version.
# When unpin hacking, it has possibility to install too legacy version of hacking.
hacking = {version = ">=5.0.0", markers="python_version >= '3.8'"}
invokelint = {version = "*", markers="python_version >= '3.7'"}
isort = "*"
mypy = "*"
pydocstyle = {version = "*", markers="python_version >= '3.6'"}
pylint = "*"
pytest = "*"
radon = "*"
ruff = {version = "*", markers="python_version >= '3.7'"}
semgrep = {version = "*", markers="python_version >= '3.6'"}
tomli = {version = "*", markers="python_version >= '3.6'"}
xenon = "*"
then:
pipenv install --dev
pipenv shell
2. Implement
Create tasks.py
in project directory:
"""Tasks for maintaining the project.
Execute 'invoke --list' for guidance on using Invoke
"""
from invoke import Collection
from invokelint import dist, lint, path, style, test
ns = Collection()
ns.add_collection(dist)
ns.add_collection(lint)
ns.add_collection(path)
ns.add_collection(style)
ns.add_collection(test)
Commands may be explicitly place with a different name than they were originally given via a name kwarg (or the 2nd regular arg):
ns.add_collection(lint, 'namespace-you-wish')
See: Constructing namespaces — Invoke documentation
3. Check installation
inv --list
4. Setup target package
This package reuses setuptools
settings for package discovery for linting, formatting, and measuring coverage. You can check which package are discovered by setuptools
and your project's settings, by following command:
$ inv path
Setuptools detected packages: ['invokelint', 'invokelint.path']
Root packages: ['invokelint']
Setuptools detected Python modules: ['setup', 'tasks']
Existing test packages: ['tests']
Python file or directories to lint: ['invokelint', 'setup.py', 'tasks.py', 'tests']
Python file or directories to lint excluding test packages: ['invokelint', 'setup.py', 'tasks.py']
If result is not your expected, follow official documentation of setuptools
to configure pyproject.toml
(recommended), setup.cfg
, or setup.py
.
See: Package Discovery and Namespace Packages - setuptools latest documentation
Credits
This package was created with Cookiecutter and the yukihiko-shinoda/cookiecutter-pypackage project template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file invokelint-0.9.1.tar.gz
.
File metadata
- Download URL: invokelint-0.9.1.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aac36510a2be730242d74c5ae348b581b4cd7e4ddedce237aa17d5e31ff397f3 |
|
MD5 | 29367f8c47233db0bc11a68fe764aa73 |
|
BLAKE2b-256 | 34037a9da832d636550fac72374868deb214c576945366b2cc02983f8d278f93 |
Provenance
File details
Details for the file invokelint-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: invokelint-0.9.1-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c13a6649a40daba93c6535017bbaf1d701c4eb8c5452d57a2c784bfd71f1adb9 |
|
MD5 | 38502a0eb3b614a467f6c7dcd6e78366 |
|
BLAKE2b-256 | 32993b106847747a571763ba7454e2fb1895d7a6b4051b179666d9a5cc6a8d81 |