Skip to content
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

docs: remove . from check and format commands #10217

Merged
merged 5 commits into from Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -129,7 +129,7 @@ and with [a variety of other package managers](https://docs.astral.sh/ruff/insta
To run Ruff as a linter, try any of the following:

```shell
ruff check . # Lint all files in the current directory (and any subdirectories).
ruff check # Lint all files in the current directory (and any subdirectories).
ruff check path/to/code/ # Lint all files in `/path/to/code` (and any subdirectories).
ruff check path/to/code/*.py # Lint all `.py` files in `/path/to/code`.
ruff check path/to/code/to/file.py # Lint `file.py`.
Expand All @@ -139,7 +139,7 @@ ruff check @arguments.txt # Lint using an input file, treating its con
Or, to run Ruff as a formatter:

```shell
ruff format . # Format all files in the current directory (and any subdirectories).
ruff format # Format all files in the current directory (and any subdirectories).
ruff format path/to/code/ # Format all files in `/path/to/code` (and any subdirectories).
ruff format path/to/code/*.py # Format all `.py` files in `/path/to/code`.
ruff format path/to/code/to/file.py # Format `file.py`.
Expand Down
9 changes: 5 additions & 4 deletions docs/formatter.md
Expand Up @@ -11,8 +11,9 @@ The Ruff formatter is available as of Ruff [v0.1.2](https://astral.sh/blog/the-r
directories, and formats all discovered Python files:

```shell
ruff format . # Format all files in the current directory.
ruff format /path/to/file.py # Format a single file.
ruff format # Format all files in the current directory.
ruff format path/to/code/ # Lint all files in `path/to/code` (and any subdirectories).
ruff format path/to/file.py # Format a single file.
```

Similar to Black, running `ruff format /path/to/file.py` will format the given file or directory
Expand Down Expand Up @@ -422,8 +423,8 @@ Currently, the Ruff formatter does not sort imports. In order to both sort impor
call the Ruff linter and then the formatter:

```shell
ruff check --select I --fix .
ruff format .
ruff check --select I --fix
ruff format
```

A unified command for both linting and formatting is [planned](https://github.com/astral-sh/ruff/issues/8232).
8 changes: 4 additions & 4 deletions docs/installation.md
Expand Up @@ -9,8 +9,8 @@ pip install ruff
Once installed, you can run Ruff from the command line:

```shell
ruff check . # Lint all files in the current directory.
ruff format . # Format all files in the current directory.
ruff check # Lint all files in the current directory.
ruff format # Format all files in the current directory.
```

For **macOS Homebrew** and **Linuxbrew** users, Ruff is also available as [`ruff`](https://formulae.brew.sh/formula/ruff)
Expand Down Expand Up @@ -58,8 +58,8 @@ On **Docker**, it is published as `ghcr.io/astral-sh/ruff`, tagged for each rele
the latest release.

```shell
docker run -v .:/io --rm ghcr.io/astral-sh/ruff check .
docker run -v .:/io --rm ghcr.io/astral-sh/ruff:0.1.3 check .
docker run -v .:/io --rm ghcr.io/astral-sh/ruff check
docker run -v .:/io --rm ghcr.io/astral-sh/ruff:0.1.3 check
```

[![Packaging status](https://repology.org/badge/vertical-allrepos/ruff-python-linter.svg?exclude_unsupported=1)](https://repology.org/project/ruff-python-linter/versions)
14 changes: 8 additions & 6 deletions docs/linter.md
Expand Up @@ -11,15 +11,17 @@ and more.
directories, and lints all discovered Python files, optionally fixing any fixable errors:

```shell
ruff check . # Lint all files in the current directory.
ruff check . --fix # Lint all files in the current directory, and fix any fixable errors.
ruff check . --watch # Lint all files in the current directory, and re-lint on change.
ruff check # Lint all files in the current directory.
ruff check --fix # Lint all files in the current directory, and fix any fixable errors.
ruff check --watch # Lint all files in the current directory, and re-lint on change.
ruff check path/to/code/ # Lint all files in `path/to/code` (and any subdirectories).
```

For the full list of supported options, run `ruff check --help`.

!!! note
As of Ruff v0.1.7 the `ruff check` command uses the current working directory (`.`) as the default path to check.
On older versions, you must provide this manually e.g. `ruff check .`.
See [the file discovery documentation](configuration.md#python-file-discovery) for details.

## Rule selection
Expand Down Expand Up @@ -150,7 +152,7 @@ imports, reformat docstrings, rewrite type annotations to use newer Python synta
To enable fixes, pass the `--fix` flag to `ruff check`:

```shell
ruff check . --fix
ruff check --fix
```

By default, Ruff will fix all violations for which safe fixes are available; to determine
Expand Down Expand Up @@ -197,10 +199,10 @@ Ruff only enables safe fixes by default. Unsafe fixes can be enabled by settings

```shell
# Show unsafe fixes
ruff check . --unsafe-fixes
ruff check --unsafe-fixes

# Apply unsafe fixes
ruff check . --fix --unsafe-fixes
ruff check --fix --unsafe-fixes
```

By default, Ruff will display a hint when unsafe fixes are available but not enabled. The suggestion can be silenced
Expand Down
20 changes: 13 additions & 7 deletions docs/tutorial.md
Expand Up @@ -38,7 +38,7 @@ def sum_even_numbers(numbers: Iterable[int]) -> int:
We can run the Ruff linter over our project via `ruff check`:

```shell
❯ ruff check .
❯ ruff check
numbers/numbers.py:3:8: F401 [*] `os` imported but unused
Found 1 error.
[*] 1 fixable with the `--fix` option.
Expand All @@ -48,7 +48,7 @@ Ruff identified an unused import, which is a common error in Python code. Ruff c
"fixable" error, so we can resolve the issue automatically by running `ruff check --fix`:

```shell
❯ ruff check --fix .
❯ ruff check --fix
Found 1 error (1 fixed, 0 remaining).
```

Expand All @@ -71,10 +71,16 @@ def sum_even_numbers(numbers: Iterable[int]) -> int:
)
```

Note Ruff runs in the current directory by default, but you can pass specific paths to check:

```shell
❯ ruff check numbers/numbers.py
```

Now that our project is passing `ruff check`, we can run the Ruff formatter via `ruff format`:

```shell
❯ ruff format .
❯ ruff format
1 file reformatted
```

Expand Down Expand Up @@ -135,7 +141,7 @@ To configure Ruff, let's create a configuration file in our project's root direc
Running Ruff again, we see that it now enforces a maximum line width, with a limit of 79:

```shell
❯ ruff check .
❯ ruff check
numbers/numbers.py:5:80: E501 Line too long (90 > 79)
Found 1 error.
```
Expand Down Expand Up @@ -217,7 +223,7 @@ If we run Ruff again, we'll see that it now enforces the pyupgrade rules. In par
the use of the deprecated `typing.Iterable` instead of `collections.abc.Iterable`:

```shell
❯ ruff check .
❯ ruff check
numbers/numbers.py:1:1: UP035 [*] Import from `collections.abc` instead: `Iterable`
Found 1 error.
[*] 1 fixable with the `--fix` option.
Expand Down Expand Up @@ -260,7 +266,7 @@ all functions have docstrings:
If we run Ruff again, we'll see that it now enforces the pydocstyle rules:

```shell
❯ ruff check .
❯ ruff check
numbers/__init__.py:1:1: D104 Missing docstring in public package
numbers/numbers.py:1:1: UP035 [*] Import from `collections.abc` instead: `Iterable`
numbers/numbers.py:1:1: D100 Missing docstring in public module
Expand All @@ -285,7 +291,7 @@ def sum_even_numbers(numbers: Iterable[int]) -> int:
Running `ruff check` again, we'll see that it no longer flags the `Iterable` import:

```shell
❯ ruff check .
❯ ruff check
numbers/__init__.py:1:1: D104 Missing docstring in public package
numbers/numbers.py:1:1: D100 Missing docstring in public module
Found 3 errors.
Expand Down