astral-sh / astral-sh/ruff-pre-commit

[v0.6.9] I001 error on pre-commit, but not on CLI check

Open
#101 8 comments 3 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2k
Forks
105
Avg merge
8h 36m
Merged PRs (30d)
1

Description

I have those imports like this in my file:

```py
import asyncio
from enum import StrEnum
from typing import Any

from langchain.chains.llm import LLMChain
from langchain.docstore.document import Document

from app.generators.utils import (
convert_str_to_json,
get_llm,
)
# more local imports from app module...

a = 5
```

I don't have `project.toml` file.
I'm using pre-commit hooks with settings:
```yaml
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
hooks:
# Run the linter.
- id: ruff
args: [--select, I]
# Run the formatter.
- id: ruff-format
```

When I check the code in CLI I receive no errors:
```bash
ruff check --select I filename.py
All checks passed!
```

But when I try to commit changes in this file I receive error I001:
```
19 | | from app.generators.utils import (
20 | | convert_str_to_json,
21 | | get_llm,
22 | | )
27 | |
28 | | a = 5
| |_^ I001
|
= help: Organize imports
```

Python version 3.11. MacOS.
This is really weird as I receive no similar error in any other file in my project...
Thanks for help!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.