Skip to main content

lint-python-action

Tool that runs common linters on CERT Polska projects written in Python.

Includes GitHub Actions custom action.

Used linters and auto-formatters are:

pip install -U isort==5.10.1 black==22.6.0 flake8==4.0.1 mypy==0.971

Installation

$ pip install lint-python

How to configure lint-python?

Provide configuration in pyproject.toml file.

[tool.lint-python]
lint-version = "2"
source = "lint_python/" # Put your source directory
extra-requirements = "types-requests"  # Provide additional typing requirements if needed
use-mypy = false  # Turn off any tool you don't want to use

Tools are opt-out, so if you don't use static typing in your project, you can turn off any tool from linting.

If you use Github Actions, you can add it to any steps of the workflow e.g. .github/workflows/test.yml

name: Test the code
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: CERT-Polska/lint-python-action@v2
        with:
          source: karton/

Tool can be configured via with parameters, but they must be provided directly. Don't use any expansion because lint-python tool parses the workflow file on its own.

How to use it?

$ lint-python
INFO:root:Linting with isort
INFO:root:Linting with black
All done! ✨ 🍰 ✨
3 files left unchanged.
INFO:root:Linting with flake8
INFO:root:Linting with mypy
Success: no issues found in 3 source files

If you want to only perform a check without modifying files, use --check flag

$ lint-python --check

If you have not installed packages and tools required for linting, use --install flag or --install-only flag if you don't want to lint immediately after successful installation.

$ lint-python --install

Try --help for more settings.

Tips for linting your own project

If you want to introduce these linters into your project, some tools need to be preconfigured to cooperate correctly. Check https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html for more information.

Our recommended settings are:

# in pyproject.toml file:
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 88
# in .flake8, setup.cfg or tox.ini file:
[flake8]
max-line-length = 88
extend-ignore = E203, W503

Read more

Metadata

Release files for lint-python 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lint-python 2.4.0
File Size Uploaded
lint_python-2.4.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lint-python 2.4.0
File Interpreter ABI Platform
lint_python-2.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / lint_python-2.4.0.tar.gz

Download URL lint_python-2.4.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6995ce3b4b72610c9caf07ad3568cc7453064071e806eb86bb21cb78ecd49414
BLAKE2b-256 checksum
How to use checksums
9ec76ed068ec60d447814bcb8873e095844c062145ae4e1a0552c7498f29dca1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / lint_python-2.4.0-py3-none-any.whl

Download URL lint_python-2.4.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40f517fdd1fb40bd9f360fe4b075d7e5ecae4aaa23037d1f4d859d2156d2bb3e
BLAKE2b-256 checksum
How to use checksums
4b812cfbdf10218447408ebde51c9b1591b44c311a27e5b1d93477a366b3473f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release history Release notifications | RSS feed

This release

2.4.0 This release

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page