-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v0.6.9] I001 error on pre-commit, but not on CLI check #101
Comments
One more thing - the file looks like this after the precommit sorting if I use --fix flag:
It looks like it treats |
Sorry for the delay. How do you run Ruff from the CLI? Are you also passing |
FWIW, I'm seeing the same error when running the pre-commit hook and the CLI: $ pre-commit run --files src/play.py
ruff.....................................................................Failed
- hook id: ruff
- exit code: 1
ruff/src/play.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / import asyncio
2 | | from enum import StrEnum
3 | | from typing import Any
4 | |
5 | | from langchain.chains.llm import LLMChain
6 | | from langchain.docstore.document import Document
7 | |
8 | | from app.generators.utils import (
9 | | convert_str_to_json,
10 | | get_llm,
11 | | )
12 | | # more local imports from app module...
| |_^ I001
13 |
14 | a = 5
|
= help: Organize imports
Found 1 error.
[*] 1 fixable with the `--fix` option.
$ ruff check --select I src/play.py
src/play.py:1:1: I001 [*] Import block is un-sorted or un-formatted
|
1 | / import asyncio
2 | | from enum import StrEnum
3 | | from typing import Any
4 | |
5 | | from langchain.chains.llm import LLMChain
6 | | from langchain.docstore.document import Document
7 | |
8 | | from app.generators.utils import (
9 | | convert_str_to_json,
10 | | get_llm,
11 | | )
12 | | # more local imports from app module...
| |_^ I001
13 |
14 | a = 5
|
= help: Organize imports
Found 1 error.
[*] 1 fixable with the `--fix` option. |
@MichaReiser yeah, I do include
|
On another note - it feels like error in formatter as langchain is not local module so it should be in "libraries" group of imports. And it looks like it is unable to differentiate between them - at least while running from pre-commit |
Interesting. Could you try running ruff with |
Here you go:
And from pre-commit:
Apparently it classifies app.generators.utils as third-party when running as pre-commit. It correctly detects it as first-party via CLI and VS Code |
I'll try the following to check where the discrepancy is coming from:
Can you try the above and see if it still gives the same results? The |
I have those imports like this in my file:
I don't have
project.toml
file.I'm using pre-commit hooks with settings:
When I check the code in CLI I receive no errors:
ruff check --select I filename.py All checks passed!
But when I try to commit changes in this file I receive error I001:
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!
The text was updated successfully, but these errors were encountered: