astral-sh / astral-sh/ruff

isort configuration doesnt seem to respect localfolder (vs real isort) in monorepo

Open
#3,115 7 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

isort
Dominant language
Rust
Stars
49.7k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

ruff 0.0.249

run ruff check pure_check/checks/docker_active_container.py

The format that ruff isort wants doesn't agree with regular isort (which is seemingly more correct). maybe do to the default_section config on regular isort

snippet in question (works with isort config)

import rich_click as click

from lib.enums.general import CheckResult
from lib.pure_check import Target

from pure_check.checks.base_check import BaseCheck
from pure_check.rehabs.remove_active_docker import RemoveActiveDocker
from pure_check.rehabs.restart_node import RestartNode

what ruff wants me to change it to

import rich_click as click

from lib.enums.general import CheckResult
from lib.pure_check import Target
from pure_check.checks.base_check import BaseCheck
from pure_check.rehabs.remove_active_docker import RemoveActiveDocker
from pure_check.rehabs.restart_node import RestartNode

directory structure

lib
| __init__.py
├── pure_check.py
├── enums
│   ├── __init__.py
│   ├── general.py
pure_check
├── pure_check
│   ├── __init__.py
│   ├── checks
│   │   ├── __init__.py
│   │   ├── base_check.py
│   └── rehabs
│      ├── __init__.py
│       ├── remove_active_docker.py
│       └── restart_node.py

pyproject.toml

[tool.ruff.isort]
force-sort-within-sections = true
force-to-top = []
forced-separate = []
known-first-party = ["lib", "tests", "app"]
lines-after-imports = 2
no-lines-before = []

.isort.cfg (known_third_party is seeded by seed-isort-cfg)

[settings]
default_section=LOCALFOLDER
force_grid_wrap=2
force_sort_within_sections=1
force_to_top=
forced_separate=
include_trailing_comma=1
indent='    '
known_first_party=lib,tests,app
known_future_library=
known_standard_library=
# This is generated from isort-seed-config DO NOT MODIFY BY HAND
known_third_party=Levenshtein,PyInstaller,alembic,anubis,attr,autotriage_spark_monitor,backpack,billiard,blinker,boto3,bs4,cachetools,cassandra,celery,cleo,click,click_default_group,consul,dateutil,dirty_equals,distro,distutils,dns,dotenv,elasticsearch,faker,flake8,flask,flask_restful,flexmock,frozendict,git,gspread,haproxy_check,inflection,influxdb,iso8601,jinja2,jira,jira_cookie_auth,jwt,kafka,kif,kombu,lazy_object_proxy,ldap,lru,marshmallow,matplotlib,methodtools,metrics_helper,mock,more_itertools,multimethod,nltk,nomad,numpy,octillion_lib,pampy,pandas,pendulum,pika,postgresql,prometheus_api_client,prometheus_client,psycopg2,pygments,pympler,pysnmp,pyspark,pytest,pytest_describe,pytoml,pytz,re2,redis,redis_lock,requests,rethinkdb,rich_click,seaborn,setuptools,sh,simplejson,six,slack_bolt,slack_sdk,slackclient,snowflake,sqlalchemy,statsd,structlog,sumtypes,tenacity,texttable,typing_extensions,unidecode,urllib3,webargs,werkzeug,wrapt,xmltodict,yaml
length_sort=0
line_length=120
lines_after_imports=2
multi_line_output=3
no_lines_before=
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
skip=
skip_glob=citadel/node_modules/*.*
use_parentheses=1
src_paths=*/tests,*
old_finders=true

Thanks for any help

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce ruff check pure_check/checks/docker_active_container.py using the shown pyproject.toml and .isort.cfg configurations, then compare Ruff's import grouping with regular isort. Trace how default_section=LOCALFOLDER and the listed sections are interpreted; done means Ruff matches the expected isort grouping for this monorepo layout and has coverage for the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.