Skip to content

Commit

Permalink
Change: Cleanup pontos.version module API
Browse files Browse the repository at this point in the history
Mark sub modules of `pontos.version` as private which aren't considered
as public API of the module. There should be only one way on how to
import a specific class, function, variable, ...
  • Loading branch information
bjoernricks committed Jan 18, 2024
1 parent db91dbe commit 53ddf6b
Show file tree
Hide file tree
Showing 27 changed files with 37 additions and 40 deletions.
3 changes: 1 addition & 2 deletions pontos/release/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

from pontos.git import Git, GitError
from pontos.terminal import Terminal
from pontos.version import Version, VersionCalculator
from pontos.version.errors import VersionError
from pontos.version import Version, VersionCalculator, VersionError

DEFAULT_TIMEOUT = 1000
DEFAULT_CHUNK_SIZE = 4096
Expand Down
6 changes: 3 additions & 3 deletions pontos/version/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from .__version__ import __version__
from ._calculator import VersionCalculator
from .errors import VersionError
from .main import main
from .version import ParseVersionFuncType, Version, VersionUpdate
from ._errors import VersionError
from ._main import main
from ._version import ParseVersionFuncType, Version, VersionUpdate

__all__ = (
"__version__",
Expand Down
2 changes: 1 addition & 1 deletion pontos/version/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# pylint: disable=invalid-name

from .main import main
from ._main import main

if __name__ == "__main__":
main()
5 changes: 2 additions & 3 deletions pontos/version/_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
from datetime import datetime
from typing import Type

from pontos.version.errors import VersionError

from .version import Version
from ._errors import VersionError
from ._version import Version


class VersionCalculator(ABC):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pontos/version/main.py → pontos/version/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from pontos.errors import PontosError

from .parser import parse_args
from ._parser import parse_args
from .project import Project
from .schemes import VersioningScheme

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pontos/version/commands/_cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import tomlkit

from ..errors import VersionError
from ..version import Version, VersionUpdate
from .._errors import VersionError
from .._version import Version, VersionUpdate
from ._command import VersionCommand


Expand Down
4 changes: 2 additions & 2 deletions pontos/version/commands/_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import re
from typing import Generator, Literal, Optional, Tuple, Union

from ..errors import VersionError
from .._errors import VersionError
from .._version import Version, VersionUpdate
from ..schemes import PEP440VersioningScheme
from ..version import Version, VersionUpdate
from ._command import VersionCommand


Expand Down
2 changes: 1 addition & 1 deletion pontos/version/commands/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pathlib import Path
from typing import Literal, Union

from .._version import Version, VersionUpdate
from ..schemes import VersioningScheme
from ..version import Version, VersionUpdate


class VersionCommand(ABC):
Expand Down
4 changes: 2 additions & 2 deletions pontos/version/commands/_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from pathlib import Path
from typing import Literal, Union

from ..errors import VersionError
from ..version import Version, VersionUpdate
from .._errors import VersionError
from .._version import Version, VersionUpdate
from ._command import VersionCommand

VERSION_MATCH = r'var [Vv]ersion = "(.+)"'
Expand Down
4 changes: 2 additions & 2 deletions pontos/version/commands/_java.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from pathlib import Path
from typing import Any, Dict, List, Literal, Union

from ..errors import VersionError
from ..version import Version, VersionUpdate
from .._errors import VersionError
from .._version import Version, VersionUpdate
from ._command import VersionCommand


Expand Down
4 changes: 2 additions & 2 deletions pontos/version/commands/_javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from pathlib import Path
from typing import Any, Dict, Literal, Optional, Union

from ..errors import VersionError
from ..version import Version, VersionUpdate
from .._errors import VersionError
from .._version import Version, VersionUpdate
from ._command import VersionCommand


Expand Down
4 changes: 2 additions & 2 deletions pontos/version/commands/_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import tomlkit

from ..errors import VersionError
from .._errors import VersionError
from .._version import Version, VersionUpdate
from ..schemes import PEP440VersioningScheme
from ..version import Version, VersionUpdate
from ._command import VersionCommand

TEMPLATE = """# pylint: disable=invalid-name
Expand Down
4 changes: 2 additions & 2 deletions pontos/version/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from typing import Iterator, Optional

from pontos.git import DEFAULT_TAG_SORT_SUFFIX, Git, TagSort
from pontos.version.errors import VersionError

from .version import ParseVersionFuncType, Version
from ._errors import VersionError
from ._version import ParseVersionFuncType, Version


def get_last_release_versions(
Expand Down
4 changes: 2 additions & 2 deletions pontos/version/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

from typing import List, Literal, Union

from ._errors import ProjectError
from ._version import Version, VersionUpdate
from .commands import VersionCommand, get_commands
from .errors import ProjectError
from .schemes import VersioningScheme
from .version import Version, VersionUpdate

__all__ = ("Project",)

Expand Down
4 changes: 2 additions & 2 deletions pontos/version/schemes/_pep440.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from packaging.version import Version as PackagingVersion

from .._calculator import VersionCalculator
from ..errors import VersionError
from ..version import Version
from .._errors import VersionError
from .._version import Version
from ._scheme import VersioningScheme

__all__ = (
Expand Down
2 changes: 1 addition & 1 deletion pontos/version/schemes/_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Type

from .._calculator import VersionCalculator
from ..version import Version
from .._version import Version


class VersioningScheme(ABC):
Expand Down
4 changes: 2 additions & 2 deletions pontos/version/schemes/_semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from semver import VersionInfo

from .._calculator import VersionCalculator
from ..errors import VersionError
from ..version import Version
from .._errors import VersionError
from .._version import Version
from ._scheme import VersioningScheme

# Note: This regex currently support any kind of
Expand Down
2 changes: 1 addition & 1 deletion tests/release/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
get_next_release_version,
)
from pontos.testing import temp_git_repository
from pontos.version.errors import VersionError
from pontos.version import VersionError
from pontos.version.schemes import SemanticVersioningScheme


Expand Down
2 changes: 1 addition & 1 deletion tests/version/schemes/test_pep440.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import unittest
from datetime import datetime

from pontos.version.errors import VersionError
from pontos.version._errors import VersionError
from pontos.version.schemes._pep440 import PEP440Version as Version
from pontos.version.schemes._pep440 import (
PEP440VersionCalculator as VersionCalculator,
Expand Down
2 changes: 1 addition & 1 deletion tests/version/schemes/test_semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import unittest
from datetime import datetime

from pontos.version.errors import VersionError
from pontos.version._errors import VersionError
from pontos.version.schemes._pep440 import PEP440Version
from pontos.version.schemes._semantic import SemanticVersion as Version
from pontos.version.schemes._semantic import (
Expand Down
2 changes: 1 addition & 1 deletion tests/version/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import unittest

from pontos.version.errors import VersionError
from pontos.version import VersionError


class VersionErrorTestCase(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/version/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from io import StringIO

from pontos.testing import temp_directory
from pontos.version.main import VersionExitCode, main
from pontos.version._main import VersionExitCode, main


class MainTestCase(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/version/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from contextlib import redirect_stderr
from io import StringIO

from pontos.version.parser import parse_args
from pontos.version._parser import parse_args


class ParserTestCase(unittest.TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/version/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import unittest

from pontos.testing import temp_directory, temp_python_module
from pontos.version.errors import ProjectError
from pontos.version.project import Project
from pontos.version.project import Project, ProjectError
from pontos.version.schemes import PEP440VersioningScheme


Expand Down

0 comments on commit 53ddf6b

Please sign in to comment.