Skip to content

Adjusting linting

Code linting (and code fixers) are performed by ruff, which is a faster alternative to popular iflake8 but significantly faster.

py-template provides a highly opinionated set of rules which might not exactly fit your needs.

Luckily it is relatively easy to adjust these rules.

Modifying pyproject.toml

All of the ruff rules are described within [tool.ruff] and following sections (under FIX SETTINGS):

###############################################################################
#
#                                FIX SETTINGS
#
###############################################################################

[tool.black]
line-length = 79

[tool.ruff]
target-version = "py39"

What you are probably after is one of:

  • select field - allows us to choose checkers and fixers to run automatically
  • ignore field - specific erros to exclude from a larger set specified by select

Others are provided matching the following regex:

[tool.ruff.<CHECKER>]

These allow us to modify specific rules for different fixers and/or checkers.

For more information check out ruff documentation here

All of the options are available and you can tune them as you wish!