From 8dd1c8c646b5c8b595f0c5401c23908d97d4136c Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 15 May 2022 11:32:13 -0500 Subject: [PATCH 1/3] refactor!: libvcs.utils -> libvcs._internal --- CHANGES | 8 ++++---- docs/internals/dataclasses.md | 4 ++-- docs/internals/query_list.md | 4 ++-- docs/internals/run.md | 4 ++-- docs/internals/subprocess.md | 4 ++-- libvcs/__init__.py | 2 +- libvcs/{utils => _internal}/__init__.py | 0 libvcs/{utils => _internal}/dataclasses.py | 0 libvcs/{utils => _internal}/query_list.py | 0 libvcs/{utils => _internal}/run.py | 3 ++- libvcs/{utils => _internal}/subprocess.py | 0 libvcs/cmd/git.py | 2 +- libvcs/cmd/hg.py | 2 +- libvcs/cmd/svn.py | 2 +- libvcs/conftest.py | 2 +- libvcs/projects/base.py | 2 +- tests/cmd/test_core.py | 2 +- tests/projects/test_conftest.py | 2 +- tests/projects/test_git.py | 2 +- tests/projects/test_hg.py | 2 +- tests/projects/test_svn.py | 2 +- tests/utils/subprocess/test_SubprocessCommand.py | 2 +- tests/utils/test_query_list.py | 2 +- 23 files changed, 27 insertions(+), 26 deletions(-) rename libvcs/{utils => _internal}/__init__.py (100%) rename libvcs/{utils => _internal}/dataclasses.py (100%) rename libvcs/{utils => _internal}/query_list.py (100%) rename libvcs/{utils => _internal}/run.py (98%) rename libvcs/{utils => _internal}/subprocess.py (100%) diff --git a/CHANGES b/CHANGES index 17a9b01fb..9a59d3b8c 100644 --- a/CHANGES +++ b/CHANGES @@ -15,16 +15,16 @@ $ pip install --user --upgrade --pre libvcs ### Breaking changes -- {issue}`343`: `libvcs.cmd.core` (including {func}`~libvcs.utils.run.run`) have been moved to - `libvcs.utils.run`. It will be supported as an unstable, internal API. +- {issue}`343`: `libvcs.cmd.core` (including {func}`~libvcs._internal.run.run`) have been moved to + `libvcs._internal.run`. It will be supported as an unstable, internal API. ### Internals - `StrOrPath` -> `StrPath` -- {issue}`#336`: {class}`~libvcs.utils.subprocess.SubprocessCommand`: Encapsulated {mod}`subprocess` +- {issue}`#336`: {class}`~libvcs._internal.subprocess.SubprocessCommand`: Encapsulated {mod}`subprocess` call in a {func}`dataclasses.dataclass` for introspecting, modifying, mocking and controlling execution. -- Dataclass helper: {class}`~libvcs.utils.dataclasses.SkipDefaultFieldsReprMixin` +- Dataclass helper: {class}`~libvcs._internal.dataclasses.SkipDefaultFieldsReprMixin` Skip default fields in object representations. diff --git a/docs/internals/dataclasses.md b/docs/internals/dataclasses.md index 109e18b3e..4fb4bc15e 100644 --- a/docs/internals/dataclasses.md +++ b/docs/internals/dataclasses.md @@ -1,7 +1,7 @@ -# `libvcs.utils.dataclasses` +# `libvcs._internal.dataclasses` ```{eval-rst} -.. autoapimodule:: libvcs.utils.dataclasses +.. autoapimodule:: libvcs._internal.dataclasses :members: :special-members: diff --git a/docs/internals/query_list.md b/docs/internals/query_list.md index 6fa74e435..2f40935c4 100644 --- a/docs/internals/query_list.md +++ b/docs/internals/query_list.md @@ -1,6 +1,6 @@ -# `libvcs.utils.query_list` +# `libvcs._internal.query_list` ```{eval-rst} -.. autoapimodule:: libvcs.utils.query_list +.. autoapimodule:: libvcs._internal.query_list :members: ``` diff --git a/docs/internals/run.md b/docs/internals/run.md index c8ebcb208..9fc0501a8 100644 --- a/docs/internals/run.md +++ b/docs/internals/run.md @@ -1,7 +1,7 @@ -# `libvcs.utils.run` +# `libvcs._internal.run` ```{eval-rst} -.. autoapimodule:: libvcs.utils.run +.. autoapimodule:: libvcs._internal.run :members: :show-inheritance: :undoc-members: diff --git a/docs/internals/subprocess.md b/docs/internals/subprocess.md index 4c562310f..16d4af6e8 100644 --- a/docs/internals/subprocess.md +++ b/docs/internals/subprocess.md @@ -1,7 +1,7 @@ -# `libvcs.utils.subprocess` +# `libvcs._internal.subprocess` ```{eval-rst} -.. autoapimodule:: libvcs.utils.subprocess +.. autoapimodule:: libvcs._internal.subprocess :members: :exclude-members: StrOrBytesPath, F, args, bufsize, diff --git a/libvcs/__init__.py b/libvcs/__init__.py index 7d769aab2..24a263a0b 100644 --- a/libvcs/__init__.py +++ b/libvcs/__init__.py @@ -1,7 +1,7 @@ """Project package for libvcs.""" import logging -from .utils.run import CmdLoggingAdapter +from ._internal.run import CmdLoggingAdapter from .projects.base import BaseProject from .projects.git import GitProject from .projects.hg import MercurialProject diff --git a/libvcs/utils/__init__.py b/libvcs/_internal/__init__.py similarity index 100% rename from libvcs/utils/__init__.py rename to libvcs/_internal/__init__.py diff --git a/libvcs/utils/dataclasses.py b/libvcs/_internal/dataclasses.py similarity index 100% rename from libvcs/utils/dataclasses.py rename to libvcs/_internal/dataclasses.py diff --git a/libvcs/utils/query_list.py b/libvcs/_internal/query_list.py similarity index 100% rename from libvcs/utils/query_list.py rename to libvcs/_internal/query_list.py diff --git a/libvcs/utils/run.py b/libvcs/_internal/run.py similarity index 98% rename from libvcs/utils/run.py rename to libvcs/_internal/run.py index 737858888..7cadbed23 100644 --- a/libvcs/utils/run.py +++ b/libvcs/_internal/run.py @@ -1,6 +1,7 @@ """Misc. legacy helpers :mod:`subprocess` and finding VCS binaries. -:class:`libvcs.utils.run.run` will be deprecated by :mod:`libvcs.utils.subprocess`. +:class:`libvcs._internal.run.run` will be deprecated by +:mod:`libvcs._internal.subprocess`. Note ---- diff --git a/libvcs/utils/subprocess.py b/libvcs/_internal/subprocess.py similarity index 100% rename from libvcs/utils/subprocess.py rename to libvcs/_internal/subprocess.py diff --git a/libvcs/cmd/git.py b/libvcs/cmd/git.py index 5e3169389..416746178 100644 --- a/libvcs/cmd/git.py +++ b/libvcs/cmd/git.py @@ -3,7 +3,7 @@ from typing import Any, Literal, Optional, Sequence, Union from ..types import StrOrBytesPath, StrPath -from libvcs.utils.run import run +from libvcs._internal.run import run _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]] diff --git a/libvcs/cmd/hg.py b/libvcs/cmd/hg.py index 9638ef9b9..0b116010a 100644 --- a/libvcs/cmd/hg.py +++ b/libvcs/cmd/hg.py @@ -3,7 +3,7 @@ from typing import Optional, Sequence, Union from ..types import StrOrBytesPath, StrPath -from libvcs.utils.run import run +from libvcs._internal.run import run _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]] diff --git a/libvcs/cmd/svn.py b/libvcs/cmd/svn.py index e46c112db..836f8ded8 100644 --- a/libvcs/cmd/svn.py +++ b/libvcs/cmd/svn.py @@ -2,7 +2,7 @@ from typing import Literal, Optional, Sequence, Union from ..types import StrOrBytesPath, StrPath -from libvcs.utils.run import run +from libvcs._internal.run import run _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]] diff --git a/libvcs/conftest.py b/libvcs/conftest.py index 71d6502bb..83f561dd5 100644 --- a/libvcs/conftest.py +++ b/libvcs/conftest.py @@ -10,7 +10,7 @@ from faker import Faker -from libvcs.utils.run import run, which +from libvcs._internal.run import run, which from libvcs.projects.git import GitProject, GitRemoteDict skip_if_git_missing = pytest.mark.skipif( diff --git a/libvcs/projects/base.py b/libvcs/projects/base.py index 01382a9ef..3a397660d 100644 --- a/libvcs/projects/base.py +++ b/libvcs/projects/base.py @@ -5,7 +5,7 @@ from urllib import parse as urlparse from libvcs.types import StrPath -from libvcs.utils.run import CmdLoggingAdapter, mkdir_p, run +from libvcs._internal.run import CmdLoggingAdapter, mkdir_p, run logger = logging.getLogger(__name__) diff --git a/tests/cmd/test_core.py b/tests/cmd/test_core.py index 62461e831..5664a9f7a 100644 --- a/tests/cmd/test_core.py +++ b/tests/cmd/test_core.py @@ -2,7 +2,7 @@ import pytest -from libvcs.utils.run import mkdir_p, which +from libvcs._internal.run import mkdir_p, which def test_mkdir_p(tmp_path: pathlib.Path): diff --git a/tests/projects/test_conftest.py b/tests/projects/test_conftest.py index 03c765bec..38a495991 100644 --- a/tests/projects/test_conftest.py +++ b/tests/projects/test_conftest.py @@ -2,7 +2,7 @@ import pytest -from libvcs.utils.run import which +from libvcs._internal.run import which from libvcs.conftest import CreateProjectCallbackFixtureProtocol diff --git a/tests/projects/test_git.py b/tests/projects/test_git.py index f72700400..d9bcaf692 100644 --- a/tests/projects/test_git.py +++ b/tests/projects/test_git.py @@ -10,7 +10,7 @@ from pytest_mock import MockerFixture from libvcs import exc -from libvcs.utils.run import run, which +from libvcs._internal.run import run, which from libvcs.conftest import CreateProjectCallbackFixtureProtocol from libvcs.projects.git import ( GitFullRemoteDict, diff --git a/tests/projects/test_hg.py b/tests/projects/test_hg.py index ff38bd27e..849dbdfa7 100644 --- a/tests/projects/test_hg.py +++ b/tests/projects/test_hg.py @@ -3,7 +3,7 @@ import pytest -from libvcs.utils.run import run, which +from libvcs._internal.run import run, which from libvcs.shortcuts import create_project, create_project_from_pip_url if not which("hg"): diff --git a/tests/projects/test_svn.py b/tests/projects/test_svn.py index 3f099ff5f..0ccc39b0b 100644 --- a/tests/projects/test_svn.py +++ b/tests/projects/test_svn.py @@ -4,7 +4,7 @@ import pytest -from libvcs.utils.run import which +from libvcs._internal.run import which from libvcs.conftest import CreateProjectCallbackFixtureProtocol from libvcs.projects.svn import SubversionProject from libvcs.shortcuts import create_project_from_pip_url diff --git a/tests/utils/subprocess/test_SubprocessCommand.py b/tests/utils/subprocess/test_SubprocessCommand.py index eeba7b472..38ecff03d 100644 --- a/tests/utils/subprocess/test_SubprocessCommand.py +++ b/tests/utils/subprocess/test_SubprocessCommand.py @@ -4,7 +4,7 @@ import pytest -from libvcs.utils.subprocess import SubprocessCommand +from libvcs._internal.subprocess import SubprocessCommand def idfn(val: Any) -> str: diff --git a/tests/utils/test_query_list.py b/tests/utils/test_query_list.py index 6e0da2b17..3af208fd9 100644 --- a/tests/utils/test_query_list.py +++ b/tests/utils/test_query_list.py @@ -2,7 +2,7 @@ import pytest -from libvcs.utils.query_list import QueryList +from libvcs._internal.query_list import QueryList @pytest.mark.parametrize( From ad3a7f6989730bc06911f950a39621d53f486898 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 15 May 2022 11:39:38 -0500 Subject: [PATCH 2/3] refactor(tests): tests/utils -> tests/_internal --- tests/{utils => _internal}/subprocess/conftest.py | 0 tests/{utils => _internal}/subprocess/test_SubprocessCommand.py | 0 tests/{utils => _internal}/test_query_list.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tests/{utils => _internal}/subprocess/conftest.py (100%) rename tests/{utils => _internal}/subprocess/test_SubprocessCommand.py (100%) rename tests/{utils => _internal}/test_query_list.py (100%) diff --git a/tests/utils/subprocess/conftest.py b/tests/_internal/subprocess/conftest.py similarity index 100% rename from tests/utils/subprocess/conftest.py rename to tests/_internal/subprocess/conftest.py diff --git a/tests/utils/subprocess/test_SubprocessCommand.py b/tests/_internal/subprocess/test_SubprocessCommand.py similarity index 100% rename from tests/utils/subprocess/test_SubprocessCommand.py rename to tests/_internal/subprocess/test_SubprocessCommand.py diff --git a/tests/utils/test_query_list.py b/tests/_internal/test_query_list.py similarity index 100% rename from tests/utils/test_query_list.py rename to tests/_internal/test_query_list.py From a03cfc9fd478d66183628566d5cb6189bfa7ecbb Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 15 May 2022 11:37:39 -0500 Subject: [PATCH 3/3] docs(CHANGES): Note module move --- CHANGES | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 9a59d3b8c..be4776212 100644 --- a/CHANGES +++ b/CHANGES @@ -20,10 +20,12 @@ $ pip install --user --upgrade --pre libvcs ### Internals +- {issue}`345` `libvcs.utils` -> `libvcs._internal` to make it more obvious the APIs are strictly + closed. - `StrOrPath` -> `StrPath` -- {issue}`#336`: {class}`~libvcs._internal.subprocess.SubprocessCommand`: Encapsulated {mod}`subprocess` - call in a {func}`dataclasses.dataclass` for introspecting, modifying, mocking and controlling - execution. +- {issue}`#336`: {class}`~libvcs._internal.subprocess.SubprocessCommand`: Encapsulated + {mod}`subprocess` call in a {func}`dataclasses.dataclass` for introspecting, modifying, mocking + and controlling execution. - Dataclass helper: {class}`~libvcs._internal.dataclasses.SkipDefaultFieldsReprMixin` Skip default fields in object representations.