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: Add paragraph about @ operator #5822

Merged
merged 6 commits into from
Jun 19, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ poetry add "pendulum>=2.0.5"
poetry add pendulum==2.0.5
```

{{% note %}}
See the [Dependency specification]({{< relref "dependency-specification#using-the--operator" >}}) page for more information about `@` operator.
Secrus marked this conversation as resolved.
Show resolved Hide resolved
{{% /note %}}

If you try to add a package that is already present, you will get an error.
However, if you specify a constraint, like above, the dependency will be updated
by using the specified constraint.
Expand Down
34 changes: 34 additions & 0 deletions docs/dependency-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,40 @@ You can specify the exact version of a package.
This will tell Poetry to install this version and this version only.
If other dependencies require a different version, the solver will ultimately fail and abort any install or update procedures.

### Using the `@` operator

When adding dependencies via CLI `add` command, you can use `@` operator.
Secrus marked this conversation as resolved.
Show resolved Hide resolved
This is understood the same way as `==` specifier, with one difference. After the `@` operator, you can use any
specifiers that are valid in `pyproject.toml` file. For example:
Secrus marked this conversation as resolved.
Show resolved Hide resolved

```shell
poetry add django@^4.0.0
```

Would translate to the following entry in `pyproject.toml`:
Secrus marked this conversation as resolved.
Show resolved Hide resolved
```toml
Django = "^4.0.0"
```

This operator, can also be used with in conjunction with word `latest`, to specify latest available version.
For example:
Secrus marked this conversation as resolved.
Show resolved Hide resolved
```shell
poetry add django@latest
```

Would translate to the following entry in `pyproject.toml`:
Secrus marked this conversation as resolved.
Show resolved Hide resolved
```toml
Django = "^4.0.5"
```

#### Extras

To use extras for package using the `@` operator, formula is: `package[extra]@version`, for example:
Secrus marked this conversation as resolved.
Show resolved Hide resolved

```shell
poetry add django[bcrypt]@^4.0.0
```

## `git` dependencies

To depend on a library located in a `git` repository,
Expand Down