Skip to content

Commit

Permalink
chore: update mypy >= 0.990
Browse files Browse the repository at this point in the history
update lockfile.

pip install --no-input everywhere (python-poetry#6966)

This is an extension of
python-poetry#6724. I think `pip install`
invoked by poetry should never ask for user input.

Motivation is that it happened to myself and a number of colleagues many
times that poetry got seemingly stuck while it was just waiting for a
user input because of a private pypi repository that needed
authentication.

I hope this is a valuable contribution to a tool I like a lot and would
like to use more and more :)

docs: update Windows cache path to match 1.2

Bump `xattr` version to `0.10.0`. (python-poetry#7005)

Resolves: python-poetry#6928

<!-- This is just a reminder about the most common mistakes. Please make
sure that you tick all *appropriate* boxes. But please read our
[contribution guide](https://python-poetry.org/docs/contributing/) at
least once, it will save you unnecessary review cycles! -->

- [ ] Added **tests** for changed code.
- [ ] Updated **documentation** for changed code.

<!-- If you have *any* questions to *any* of the points above, just
**submit and ask**! This checklist is here to *help* you, not to deter
you from contributing! -->

Bump `xattr` version to `0.10.0`.

This fixes python-poetry#6891, which is not a problem with the user's environment as
suggested by the maintainer of xattr at xattr/xattr#108, but in fact the
problem of the package which was fixed by xattr/xattr#106.

Looking at the [changes in the version
bump](xattr/xattr@v0.9.9...v0.10.0), there
does not seem to be any significant changes other than shabang
xattr/xattr#106.

Co-authored-by: Moonsik Park <moonsik.park@estsoft.com>
Co-authored-by: Bartosz Sokorski <b.sokorski@gmail.com>

tests: add coverage to `poetry install`

update lockfile.

[pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v3.2.0 → v3.2.2](asottile/pyupgrade@v3.2.0...v3.2.2)
- [github.com/hadialqattan/pycln: v2.1.1 → v2.1.2](hadialqattan/pycln@v2.1.1...v2.1.2)
  • Loading branch information
moonsikpark committed Nov 15, 2022
1 parent c781157 commit 1bb1bba
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 88 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -47,14 +47,14 @@ repos:
- flake8-pie==0.16.0

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py37-plus]
exclude: ^(install|get)-poetry.py$

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.1
rev: v2.1.2
hooks:
- id: pycln
args: [--all]
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Expand Up @@ -138,7 +138,7 @@ You can override the Data directory by setting the `POETRY_DATA_DIR` or `POETRY_
### Cache Directory

- Linux: `$XDG_CACHE_HOME/pypoetry` or `~/.cache/pypoetry`
- Windows: `%APPDATA%\pypoetry\Cache`
- Windows: `%LOCALAPPDATA%\pypoetry`
- MacOS: `~/Library/Caches/pypoetry`

You can override the Cache directory by setting the `POETRY_CACHE_DIR` environment variable.
Expand Down
171 changes: 89 additions & 82 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Expand Up @@ -73,7 +73,7 @@ tomlkit = ">=0.11.1,<1.0.0,!=0.11.2,!=0.11.3"
trove-classifiers = "^2022.5.19"
# exclude 20.4.5 - 20.4.6 due to https://github.com/pypa/pip/issues/9953
virtualenv = "^20.4.3,!=20.4.5,!=20.4.6"
xattr = { version = "^0.9.7", markers = "sys_platform == 'darwin'" }
xattr = { version = "^0.10.0", markers = "sys_platform == 'darwin'" }
urllib3 = "^1.26.0"

[tool.poetry.group.dev.dependencies]
Expand All @@ -93,7 +93,7 @@ pytest-xdist = { version = "^2.5", extras = ["psutil"] }
zipp = { version = "^3.4", python = "<3.8" }

[tool.poetry.group.typing.dependencies]
mypy = ">=0.971"
mypy = ">=0.990"
types-html5lib = ">=1.1.9"
types-jsonschema = ">=4.9.0"
types-requests = ">=2.28.8"
Expand Down
1 change: 1 addition & 0 deletions src/poetry/inspection/info.py
Expand Up @@ -593,6 +593,7 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
"install",
"--disable-pip-version-check",
"--ignore-installed",
"--no-input",
*PEP517_META_BUILD_DEPS,
)
venv.run(
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/installation/pip_installer.py
Expand Up @@ -46,7 +46,7 @@ def install(self, package: Package, update: bool = False) -> None:

return

args = ["install", "--no-deps"]
args = ["install", "--no-deps", "--no-input"]

if not package.is_direct_origin() and package.source_url:
assert package.source_reference is not None
Expand Down
1 change: 1 addition & 0 deletions src/poetry/utils/env.py
Expand Up @@ -1953,6 +1953,7 @@ def build_environment(
"install",
"--disable-pip-version-check",
"--ignore-installed",
"--no-input",
*poetry.pyproject.build_system.requires,
)

Expand Down
96 changes: 96 additions & 0 deletions tests/console/commands/test_install.py
Expand Up @@ -169,6 +169,17 @@ def test_all_extras_populates_installer(tester: CommandTester, mocker: MockerFix
assert tester.command.installer._extras == ["extras-a", "extras-b"]


def test_extras_are_parsed_and_populate_installer(
tester: CommandTester,
mocker: MockerFixture,
):
mocker.patch.object(tester.command.installer, "run", return_value=0)

tester.execute('--extras "first second third"')

assert tester.command.installer._extras == ["first", "second", "third"]


def test_extras_conflicts_all_extras(tester: CommandTester, mocker: MockerFixture):
"""
The --extras doesn't make sense with --all-extras.
Expand All @@ -185,6 +196,48 @@ def test_extras_conflicts_all_extras(tester: CommandTester, mocker: MockerFixtur
)


@pytest.mark.parametrize(
"options",
[
"--with foo",
"--without foo",
"--with foo,bar --without baz",
"--only foo",
],
)
def test_only_root_conflicts_with_without_only(
options: str,
tester: CommandTester,
mocker: MockerFixture,
):
mocker.patch.object(tester.command.installer, "run", return_value=0)

tester.execute(f"{options} --only-root")

assert tester.status_code == 1
assert (
tester.io.fetch_error()
== "The `--with`, `--without` and `--only` options cannot be used with"
" the `--only-root` option.\n"
)


def test_remove_untracked_outputs_deprecation_warning(
tester: CommandTester,
mocker: MockerFixture,
):
mocker.patch.object(tester.command.installer, "run", return_value=0)

tester.execute("--remove-untracked")

assert tester.status_code == 0
assert (
tester.io.fetch_error()
== "The `--remove-untracked` option is deprecated, use the `--sync` option"
" instead.\n"
)


def test_dry_run_populates_installer(tester: CommandTester, mocker: MockerFixture):
"""
The --dry-run option results in extras passed to the installer.
Expand All @@ -195,3 +248,46 @@ def test_dry_run_populates_installer(tester: CommandTester, mocker: MockerFixtur
tester.execute("--dry-run")

assert tester.command.installer._dry_run is True


def test_dry_run_does_not_build(tester: CommandTester, mocker: MockerFixture):
mocker.patch.object(tester.command.installer, "run", return_value=0)
mocked_editable_builder = mocker.patch(
"poetry.masonry.builders.editable.EditableBuilder"
)

tester.execute("--dry-run")

assert mocked_editable_builder.return_value.build.call_count == 0


def test_install_logs_output(tester: CommandTester, mocker: MockerFixture):
mocker.patch.object(tester.command.installer, "run", return_value=0)
mocker.patch("poetry.masonry.builders.editable.EditableBuilder")

tester.execute()

assert tester.status_code == 0
assert (
tester.io.fetch_output()
== "\nInstalling the current project: simple-project (1.2.3)\n"
)


def test_install_logs_output_decorated(tester: CommandTester, mocker: MockerFixture):
mocker.patch.object(tester.command.installer, "run", return_value=0)
mocker.patch("poetry.masonry.builders.editable.EditableBuilder")

tester.execute(decorated=True)

expected = (
"\n"
"\x1b[39;1mInstalling\x1b[39;22m the current project: "
"\x1b[36msimple-project\x1b[39m (\x1b[39;1m1.2.3\x1b[39;22m)"
"\x1b[1G\x1b[2K"
"\x1b[39;1mInstalling\x1b[39;22m the current project: "
"\x1b[36msimple-project\x1b[39m (\x1b[32m1.2.3\x1b[39m)"
"\n"
)
assert tester.status_code == 0
assert tester.io.fetch_output() == expected
1 change: 1 addition & 0 deletions tests/utils/test_env.py
Expand Up @@ -1535,6 +1535,7 @@ def test_build_environment_called_build_script_specified(
"install",
"--disable-pip-version-check",
"--ignore-installed",
"--no-input",
*extended_without_setup_poetry.pyproject.build_system.requires,
]
]
Expand Down

0 comments on commit 1bb1bba

Please sign in to comment.