使用一个插入符号(^)和一个 @ 符号添加诗歌。

huangapple go评论209阅读模式
英文:

poetry add using a caret and a @ symbol

问题

I am confused as to what the "@" operator actually does in poetry add pandas@^1.3.0.

Both following commands install pandas version 1.5.3 and set the dependency in my pyproject.toml to pandas = "^1.3.0":

poetry add pandas@^1.3.0
poetry add pandas^1.3.0

I have no other dependencies listed (aside from Python 3.8).

I thought that using the "@" symbol signifies a strict requirement for a specific version and its compatible releases. With "pandas@^1.3.0," shouldn't Poetry install exactly the version 1.3.0 of the "pandas" package?

The official documentation says:

When adding dependencies via poetry add, you can use the @ operator.
This is understood similarly to the == syntax, but also allows
prefixing any specifiers that are valid in pyproject.toml. For
example:

英文:

I am confused as to what the "@" operator actually does in poetry add pandas@^1.3.0.

Both following commands install pandas version 1.5.3 and set the dependency in my pyproject.toml to pandas = "^1.3.0":

poetry add pandas@^1.3.0
poetry add pandas^1.3.0

I have no other dependencies listed (aside from Python 3.8).

I thought that using the "@" symbol signifies a strict requirement for a specific version and its compatible releases. With "pandas@^1.3.0," shouldn't Poetry install exactly the version 1.3.0 of the "pandas" package?

The official documentation says:

> When adding dependencies via poetry add, you can use the @ operator.
> This is understood similarly to the == syntax, but also allows
> prefixing any specifiers that are valid in pyproject.toml. For
> example:

答案1

得分: 2

The "@" operator in the add command is a delimiter between the package name and the version.

If the "@" operator is followed by its required version, e.g.

poetry add pendulum@2.0.5

is the same as:

poetry add pendulum==2.0.5

If you use caret, e.g.:

poetry add requests@^2.13.0

Then you specify a version range.

The "@" symbol signifies a strict requirement only if you don't use any other specifier afterwards. The poetry documentation for "@" operator is a bit confusing.

英文:

The "@" operator in the add command is a delimiter between the package name and the version.

If the "@" operator is followed by its required version, e.g.

poetry add pendulum@2.0.5

is the same as:

poetry add pendulum==2.0.5

If you use caret, e.g.:

poetry add requests@^2.13.0

Then you specify a version range.

The "@" symbol signifies a strict requirement only if you don't use any other specifier afterwards. The poetry documentation for "@" operator is a bit confusing.

答案2

得分: 0

如果意图是固定软件包到特定版本,那么应该使用 "==",这在以下链接中明确说明:https://python-poetry.org/docs/dependency-specification/#exact-requirements

关于你的问题,你尝试的有以下几种方式:

  • poetry add pandas@^1.3.0
  • poetry add pandas^1.3.0

插入符(^)允许升级到一个稍后的版本,只要它不修改最左边的非零(主要版本)数字。所以即使你写了^1.3.0,它会找到 pandas 主要版本为 1 的最新版本(https://pypi.org/project/pandas/#history),即 1.5.3。

如果你坚持使用 @ 符号,请尝试 "poetry add pandas@1.3.0"。

英文:

If the intention is to pin the package to a specific version, then "==" is what we must be using, and it clearly outlined in : https://python-poetry.org/docs/dependency-specification/#exact-requirements

Coming to your question, what you have attempted are the below:

poetry add pandas@^1.3.0

poetry add pandas^1.3.0

The caret(^) symbol allows upgrades to a later version as long as it doesn't modify the left most non-zero(major version) digit. So even though you say ^1.3.0, it finds the latest version of pandas with major version 1 (https://pypi.org/project/pandas/#history), which is 1.5.3.

If you are keen on using @ ,please do give a try with "poetry add pandas@1.3.0".

答案3

得分: 0

不应该。根据文档,它要求pandas包的最低版本是1.3.0,最高版本严格小于2.0.0参考链接# 允许>=2.0.5,<3.0.0版本 poetry add pendulum@^2.0.5

英文:

> With "pandas@^1.3.0," shouldn't Poetry install exactly the version 1.3.0 of the "pandas" package?

No. According to the docs it requires that the minimal version is 1.3.0
and the maximal is strictly less than 2.0.0. Reference:

# Allow &gt;=2.0.5, &lt;3.0.0 versions
poetry add pendulum@^2.0.5

huangapple
  • 本文由 发表于 2023年6月15日 13:58:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76479504.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定