Skip to main content

CLI tool used for running linter on project configured with CERT-Polska/lint-python-action

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lint-python-2.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

lint_python-2.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file lint-python-2.1.1.tar.gz.

File metadata

  • Download URL: lint-python-2.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for lint-python-2.1.1.tar.gz
Algorithm Hash digest
SHA256 65b5b195e8e8f836c829653429b03c83176b82a1572622f4d7c64ee0a1401afc
MD5 846deffb477fc38d09487f2d414d1832
BLAKE2b-256 6b052e9faf9286b3751686b98dd76a5777fd9ef2483ad8971b4aaf2cbec9c48e

See more details on using hashes here.

File details

Details for the file lint_python-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: lint_python-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for lint_python-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 111e6c0bf6583357c411f55a625b53cdaf1f4386023ab3f23ff240aae76d10c2
MD5 9b83ea48ad9516f474a3f8fee5dac487
BLAKE2b-256 92587e93c22a3836813e502584c1aae0403819bc5cd19b7e310c2beab02515ec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page