Skip to content

BesLogic/Beslogic-Ruff-Config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This only works on setups with a virtual environment at a known consistent location. This way of installing is a workaround until an official solution is available. See astral-sh/ruff#12352.
Alternatively, you can simply copy the ruff.toml skeleton file into the root of your python project or root of your monorepo.

required-version and project.dependencies are already set so you shouldn't be able to accidentally use an incompatible Ruff version.
Although there was an issue before 0.14.11 where config parsing may fail before required-version tells you about it: astral-sh/ruff#19922

Usage

To use, simply extend your Ruff configuration with the one from this project.

# ruff.toml
extend = ".venv/Beslogic-Ruff-Config/ruff.toml"

Using in CI

GitHub action example:

jobs:
  Ruff:
    runs-on: ubuntu-latest
    env:
      RUFF_OUTPUT_FORMAT: github
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v7
        with:
          activate-environment: true
      - run: uv sync --locked --only-group=ruff
      - run: ruff check
      - run: ruff format --check
        # Check format even if the the previous step failed
        if: ${{ !cancelled() }}

Where the ruff Dependency Group is configured as such in your pyproject.toml:

[dependency-groups]
ruff = [
  "beslogic-ruff-config",
  "ruff", # Version should come from beslogic-ruff-config and the lock file
]
dev = [
  {include-group = "ruff"},
]

Additional configuration

If a rule doesn't seem to fit your need, try to see if it's configurable before disabling it: https://docs.astral.sh/ruff/settings/#lint

Never use the following settings,
unless you really know that you want to overwrite entire config sections
Instead, always try to use
exclude extend-exclude
include extend-include
fixable extend-fixable
per-file-ignores extend-per-file-ignores
select extend-select
safe-fixes extend-safe-fixes
unsafe-fixes extend-unsafe-fixes
flake8-gettext.function-names flake8-gettext.extend-function-names
flake8-import-conventions.aliases flake8-import-conventions.extend-aliases
flake8-self.ignore-names flake8-self.extend-ignore-names
pep8-naming.ignore-names pep8-naming.extend-ignore-names

If you end up with additional configuration that you believe should be applied across all projects. Please open a PR to modify these shared configurations instead.

The following are not part of the default config and are good to know about:

Installation

Below you should replace <rev> with the latest revision/commit to pin the configuration version.

If you want to rely on the uv lockfile instead of using an explicit revision, you can run uv lock --upgrade-package Beslogic-Ruff-Config to update.

Optimized dependency groups for use in CI

See Using in CI

For a uv-based project

uv add git+https://github.com/Beslogic/Beslogic-Ruff-Config --dev --rev <rev>

Which should add the following to your pyproject.toml:

[dependency-groups]
dev = [
    "Beslogic-Ruff-Config",
]

[tool.uv.sources]
Beslogic-Ruff-Config = { git = "https://github.com/Beslogic/Beslogic-Ruff-Config@<rev>" }

Using pip

pip install git+https://github.com/microsoft/python-type-stubs.git@<rev>

About

Ruff rules and configs used at Beslogic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published