Convert from pydantic to vanilla dataclasses (includes pythonfinder 2.1.0) (#6065)

* Upgrade `pythonfinder==2.1.0`

* Try to  normalize on using pathlib basics and storing string paths in dataclass to compare against.

* Completely remove posix path conversions.

* Round 2 of pydantic conversions -- pydantic removal from pipenv.

* Add news fragment
This commit is contained in:
Matt Davis
2024-01-28 09:53:42 -07:00
committed by GitHub
parent 2bd7eab65e
commit 95df3fd649
49 changed files with 406 additions and 13645 deletions
+21 -22
View File
@@ -6,7 +6,7 @@ from tempfile import TemporaryDirectory
import pytest
from pipenv.utils.constants import FALSE_VALUES, TRUE_VALUES
from pipenv.utils.shell import normalize_drive, temp_environ
from pipenv.utils.shell import temp_environ
@pytest.mark.dotvenv
@@ -17,7 +17,7 @@ def test_venv_in_project(true_value, pipenv_instance_pypi):
with pipenv_instance_pypi() as p:
c = p.pipenv('install dataclasses-json')
assert c.returncode == 0
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
assert p.path in p.pipenv('--venv').stdout
@pytest.mark.dotvenv
@@ -39,12 +39,12 @@ def test_venv_in_project_disabled_ignores_venv(false_value, pipenv_instance_pypi
assert c.returncode == 0
c = p.pipenv('--venv')
assert c.returncode == 0
venv_loc = Path(c.stdout.strip()).absolute()
venv_loc = Path(c.stdout.strip()).resolve()
assert venv_loc.exists()
assert venv_loc.joinpath('.project').exists()
venv_path = normalize_drive(venv_loc.as_posix())
venv_expected_path = Path(workon_home).joinpath(venv_name).absolute().as_posix()
assert venv_path == normalize_drive(venv_expected_path)
venv_path = Path(venv_loc).resolve()
venv_expected_path = Path(workon_home).joinpath(venv_name).resolve()
assert os.path.samefile(venv_path, venv_expected_path)
@pytest.mark.dotvenv
@@ -54,12 +54,12 @@ def test_venv_at_project_root(true_value, pipenv_instance_pypi):
os.environ['PIPENV_VENV_IN_PROJECT'] = true_value
c = p.pipenv('install')
assert c.returncode == 0
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
assert p.path in p.pipenv('--venv').stdout
del os.environ['PIPENV_VENV_IN_PROJECT']
os.mkdir('subdir')
os.chdir('subdir')
# should still detect installed
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
assert p.path in p.pipenv('--venv').stdout
@pytest.mark.dotvenv
@@ -77,12 +77,12 @@ def test_venv_in_project_disabled_with_existing_venv_dir(false_value, pipenv_ins
assert c.returncode == 0
c = p.pipenv('--venv')
assert c.returncode == 0
venv_loc = Path(c.stdout.strip()).absolute()
venv_loc = Path(c.stdout.strip()).resolve()
assert venv_loc.exists()
assert venv_loc.joinpath('.project').exists()
venv_path = normalize_drive(venv_loc.as_posix())
venv_expected_path = Path(workon_home).joinpath(venv_name).absolute().as_posix()
assert venv_path == normalize_drive(venv_expected_path)
venv_path = Path(venv_loc).resolve()
venv_expected_path = Path(workon_home).joinpath(venv_name).resolve()
assert os.path.samefile(venv_path, venv_expected_path)
@pytest.mark.dotvenv
@@ -91,7 +91,7 @@ def test_reuse_previous_venv(pipenv_instance_pypi):
os.mkdir('.venv')
c = p.pipenv('install dataclasses-json')
assert c.returncode == 0
assert normalize_drive(p.path) in p.pipenv('--venv').stdout
assert p.path in p.pipenv('--venv').stdout
@pytest.mark.dotvenv
@@ -115,15 +115,15 @@ def test_venv_file(venv_name, pipenv_instance_pypi):
c = p.pipenv('--venv')
assert c.returncode == 0
venv_loc = Path(c.stdout.strip()).absolute()
venv_loc = Path(c.stdout.strip()).resolve()
assert venv_loc.exists()
assert venv_loc.joinpath('.project').exists()
venv_path = normalize_drive(venv_loc.as_posix())
venv_path = Path(venv_loc).resolve()
if os.path.sep in venv_name:
venv_expected_path = Path(p.path).joinpath(venv_name).absolute().as_posix()
venv_expected_path = Path(p.path).joinpath(venv_name)
else:
venv_expected_path = Path(workon_home).joinpath(venv_name).absolute().as_posix()
assert venv_path == normalize_drive(venv_expected_path)
venv_expected_path = Path(workon_home).joinpath(venv_name)
assert venv_path == venv_expected_path.resolve()
@pytest.mark.dotvenv
@@ -148,10 +148,9 @@ def test_empty_venv_file(pipenv_instance_pypi):
venv_loc = Path(c.stdout.strip()).absolute()
assert venv_loc.exists()
assert venv_loc.joinpath('.project').exists()
from pathlib import PurePosixPath
venv_path = normalize_drive(venv_loc.as_posix())
venv_path_parent = str(PurePosixPath(venv_path).parent)
assert venv_path_parent == Path(workon_home).absolute().as_posix()
venv_path = Path(venv_loc)
venv_path_parent = Path(venv_path.parent)
assert venv_path_parent == Path(workon_home)
@pytest.mark.dotvenv