How to ignore environment directory when using python ruff linter in console

2.4k Views Asked by At

I was trying ruff linter. I have a file structure like below

project_folder
├── env # Python enviroment [python -m venv env]
│   ├── Include
│   ├── Lib
│   ├── Scripts
│   ├── ...
├── __init__.py
└── numbers.py

I am trying to use this code

I activated the environment inside the project_folder and ran the script below

ruff check .

but ruff also checked the env file. Image.png

how to ignore env file like below linux script

tree -I env
2

There are 2 best solutions below

0
On BEST ANSWER

You can use the exclude option,

ruff check --exclude=env .
0
On

You can add it to your ruff configuration in your project root:

#.ruff.toml

exclude= ["env"]

See: https://docs.astral.sh/ruff/configuration/