Skip to content

Commit 688cb0c

Browse files
Merge pull request #8 from renan-r-santos/fix-recursion-bug
fix recursion error
2 parents 82ce060 + 0df9e71 commit 688cb0c

File tree

9 files changed

+751
-958
lines changed

9 files changed

+751
-958
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
run:
2222
shell: bash -el {0}
2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2525

2626
- name: Set up Miniforge on ${{ matrix.os }}
27-
uses: conda-incubator/setup-miniconda@v2
27+
uses: conda-incubator/setup-miniconda@v3
2828
with:
2929
activate-environment: ""
3030
auto-activate-base: true
@@ -33,22 +33,16 @@ jobs:
3333
miniforge-version: latest
3434

3535
- name: Install poetry
36-
run: conda install poetry=1.8.2
36+
run: conda install poetry=1.8.3
3737

3838
- name: Configure poetry
3939
run: poetry config virtualenvs.in-project true
4040

4141
- name: Install dependencies
4242
run: poetry install --no-interaction --no-ansi
4343

44-
- name: Run mypy
45-
run: poetry run mypy
46-
47-
- name: Run black
48-
run: poetry run black --check .
49-
5044
- name: Run ruff
51-
run: poetry run ruff check .
45+
run: poetry run nox -s lint mypy
5246

5347
- name: Run pytest
5448
run: poetry run pytest

.github/workflows/release.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,30 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*.*.*'
6+
- "*.*.*"
77

88
jobs:
99
release:
1010
name: Release
1111
runs-on: ubuntu-latest
12+
environment: release
1213
steps:
1314
- name: Checkout code
14-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1516

16-
- name: Set up Python 3.11
17-
uses: actions/setup-python@v4
17+
- name: Set up Python 3.12
18+
uses: actions/setup-python@v5
1819
with:
19-
python-version: "3.11"
20+
python-version: 3.12
2021

2122
- name: Install Poetry
22-
run: curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.4.0 python -
23+
run: curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.3 python -
2324

2425
- name: Update PATH
2526
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
2627

2728
- name: Build project for distribution
2829
run: poetry build
2930

30-
- name: Publish to PyPI
31-
env:
32-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
33-
run: poetry publish
31+
- name: Upload distribution to PyPI
32+
uses: pypa/gh-action-pypi-publish@release/v1

noxfile.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from nox import options, parametrize
2+
from nox_poetry import Session, session
3+
4+
options.sessions = ["lint", "mypy"]
5+
6+
7+
@session(venv_backend="none")
8+
@parametrize("command", [["ruff", "check", "."], ["ruff", "format", "--check", "."]])
9+
def lint(s: Session, command: list[str]):
10+
s.run(*command)
11+
12+
13+
@session(venv_backend="none")
14+
def format(s: Session) -> None:
15+
s.run("ruff", "check", ".", "--select", "I", "--fix")
16+
s.run("ruff", "format", ".")
17+
18+
19+
@session(venv_backend="none")
20+
def mypy(s: Session) -> None:
21+
s.run("mypy")

poetry.lock

Lines changed: 676 additions & 893 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "poetry-conda"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "Poetry plugin that allows for the creation of virtual environments using Poetry, without interfering with the Conda environment in which Poetry is installed"
55
authors = ["Renan Santos <renan.engmec@gmail.com>"]
66
license = "MIT"
@@ -23,20 +23,17 @@ classifiers = [
2323
"Typing :: Typed",
2424
]
2525

26-
packages = [
27-
{ include = "poetry_conda", from = "src" }
28-
]
26+
packages = [{ include = "poetry_conda", from = "src" }]
2927

3028
[tool.poetry.dependencies]
3129
python = "^3.8"
3230
poetry = "^1.3.0"
3331

3432
[tool.poetry.group.dev.dependencies]
35-
black = "~23.1"
36-
mypy = "~1.1"
37-
pre-commit = "~3.1"
38-
pytest = "~7.2"
39-
ruff = "0.0.255"
33+
mypy = "~1.11"
34+
pytest = "~8.3"
35+
ruff = "~0.5"
36+
nox_poetry = "^1.0.3"
4037

4138
[tool.poetry.plugins."poetry.application.plugin"]
4239
poetry-conda = "poetry_conda.plugin:PoetryCondaPlugin"
@@ -45,28 +42,25 @@ poetry-conda = "poetry_conda.plugin:PoetryCondaPlugin"
4542
requires = ["poetry-core"]
4643
build-backend = "poetry.core.masonry.api"
4744

48-
[tool.black]
49-
color = true
50-
line-length = 120
51-
target-version = ['py38']
52-
5345
[tool.mypy]
5446
files = ["src", "tests"]
5547
show_error_codes = true
5648
strict = true
5749

5850
[tool.ruff]
51+
src = ["src"]
5952
line-length = 120
60-
select = [
61-
"E", # pycodestyle errors
62-
"W", # pycodestyle warnings
63-
"F", # pyflakes
64-
"I", # isort
65-
"C", # flake8-comprehensions
66-
]
67-
ignore = [
68-
"E501", # line too long, handled by black
69-
]
7053

71-
[tool.ruff.isort]
72-
known-third-party = ["poetry"]
54+
[tool.ruff.lint]
55+
extend-select = [
56+
"I", # isort
57+
"N", # pep8-naming
58+
"RUF", # ruff
59+
"B", # flake8-bugbear
60+
"N", # flake8-broken-line
61+
"C4", # flake8-comprehensions
62+
"PIE", # flake8-pie
63+
"PT", # flake8-pytest-style
64+
"PTH", # flake8-use-pathlib
65+
"ERA", # flake8-eradicate
66+
]

src/poetry_conda/plugin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ def __init__(self, use_environment: bool = True, base_dir: Optional[Path] = None
3232
Config.default_config["virtualenvs"]["ignore-conda-env"] = True
3333
super().__init__(use_environment, base_dir)
3434

35-
@staticmethod
36-
def _get_normalizer(name: str) -> Callable[[str], Any]:
35+
@classmethod
36+
def _get_normalizer(cls, name: str) -> Callable[[str], Any]:
3737
if name == "virtualenvs.ignore-conda-env":
3838
return boolean_normalizer
39-
return config.Config._get_normalizer(name)
39+
return super()._get_normalizer(name)
4040

4141

4242
class ConfigCommand(config_command.ConfigCommand):
@@ -54,6 +54,6 @@ def unique_config_values(self) -> Dict[str, Tuple[Any, Any]]:
5454

5555
class PoetryCondaPlugin(ApplicationPlugin):
5656
def activate(self, application: Application) -> None:
57-
setattr(config, "Config", Config)
58-
setattr(config_command, "ConfigCommand", ConfigCommand)
59-
setattr(env, "EnvManager", EnvManager)
57+
config.Config = Config # type: ignore
58+
config_command.ConfigCommand = ConfigCommand # type: ignore
59+
env.EnvManager = EnvManager # type: ignore

tests/conftest.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
from typing import Iterator
77

88
import pytest
9-
from pytest import FixtureRequest
9+
10+
11+
@pytest.fixture(scope="session", autouse=True)
12+
def _use_poetry_env_var_config() -> None:
13+
# Triggers https://github.com/renan-r-santos/poetry-conda/issues/7
14+
os.environ["POETRY_VIRTUALENVS_PROMPT"] = "{project_name}-py{python_version}"
1015

1116

1217
@pytest.fixture(
@@ -15,16 +20,12 @@
1520
{"python": "3.8", "poetry": "1.3.0"},
1621
{"python": "3.9", "poetry": "1.3.0"},
1722
{"python": "3.10", "poetry": "1.3.0"},
18-
{"python": "3.11", "poetry": "1.3.0"},
19-
{"python": "3.11", "poetry": "1.4.0"},
2023
{"python": "3.11", "poetry": "1.5.1"},
21-
{"python": "3.12", "poetry": "1.6.1"},
22-
{"python": "3.12", "poetry": "1.7.1"},
23-
{"python": "3.12", "poetry": "1.8.2"},
24+
{"python": "3.12", "poetry": "1.8.3"},
2425
],
2526
ids=lambda param: f"python-{param['python']}-poetry-{param['poetry']}",
2627
)
27-
def conda_environment(request: FixtureRequest) -> Iterator[str]:
28+
def conda_environment(request: pytest.FixtureRequest) -> Iterator[str]:
2829
python_version = request.param.get("python")
2930
poetry_version = request.param.get("poetry")
3031
random_string = "".join(random.choices(ascii_letters + digits, k=8))
@@ -54,8 +55,8 @@ def conda_environment(request: FixtureRequest) -> Iterator[str]:
5455
subprocess.run(["conda", "remove", "--prefix", environment_path, "--all", "--quiet", "--yes"], check=True)
5556

5657

57-
@pytest.fixture
58-
def remove_poetry_conda_plugin(conda_environment: str) -> Iterator[None]:
58+
@pytest.fixture()
59+
def _remove_poetry_conda_plugin(conda_environment: str) -> Iterator[None]:
5960
subprocess.run(
6061
["conda", "run", "--prefix", conda_environment, "pip", "uninstall", "poetry-conda", "--yes"], check=True
6162
)
@@ -66,7 +67,7 @@ def remove_poetry_conda_plugin(conda_environment: str) -> Iterator[None]:
6667
subprocess.run(["conda", "run", "--prefix", conda_environment, "pip", "install", "--no-deps", root_dir], check=True)
6768

6869

69-
@pytest.fixture
70+
@pytest.fixture()
7071
def test_project_dir() -> Iterator[Path]:
7172
test_project_dir = Path(__file__).parent / "test_project"
7273
current_cwd = Path.cwd()

tests/test_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@pytest.mark.usefixtures("conda_environment")
1010
class TestConfig:
1111
@pytest.fixture(autouse=True)
12-
def env(self, conda_environment: str) -> None:
12+
def _env(self, conda_environment: str) -> None:
1313
self._conda_environment = conda_environment
1414

1515
def _run_command(self, command: str, check: bool = True) -> CompletedProcess[str]:
@@ -20,7 +20,8 @@ def _run_command(self, command: str, check: bool = True) -> CompletedProcess[str
2020
text=True,
2121
)
2222

23-
def test_setting_not_available_if_plugin_not_installed(self, remove_poetry_conda_plugin: None) -> None:
23+
@pytest.mark.usefixtures("_remove_poetry_conda_plugin")
24+
def test_setting_not_available_if_plugin_not_installed(self) -> None:
2425
result = self._run_command("poetry config virtualenvs.ignore-conda-env", check=False)
2526
assert result.stderr.strip().splitlines()[0] == "There is no virtualenvs.ignore-conda-env setting."
2627

tests/test_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@pytest.mark.usefixtures("conda_environment")
1010
class TestEnv:
1111
@pytest.fixture(autouse=True)
12-
def env(self, conda_environment: str) -> None:
12+
def _env(self, conda_environment: str) -> None:
1313
self._conda_environment = conda_environment
1414

1515
def _run_command(self, command: str, check: bool = True) -> CompletedProcess[str]:

0 commit comments

Comments
 (0)