Skip to content

Commit

Permalink
Merge pull request #16 from ShadowXBoss696/staging
Browse files Browse the repository at this point in the history
Draft 1
  • Loading branch information
ShadowXBoss696 authored Jul 24, 2024
2 parents a0e28ae + dab944b commit 93db292
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 55 deletions.
9 changes: 1 addition & 8 deletions fastboot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
from fastboot.version import VERSION

__all__ = ["__version__"]

# Project Information
__version__ = VERSION
__author__ = ["Arpan Mahanty <arpan.mahanty.007@gmail.com>"]
__license__ = "MIT"
from ._version import __version__ as __version__
4 changes: 4 additions & 0 deletions fastboot/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import fastboot

if __name__ == "__main__":
print("FastBoot " + fastboot.__version__)
18 changes: 18 additions & 0 deletions fastboot/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import importlib.metadata
import pathlib
import tomllib

__version__: str

# /// Internal logic -----------------------------------------------------------------------------

_build_script: pathlib.Path = pathlib.Path(__file__).parents[1] / "pyproject.toml"

if _build_script.exists():
# We know we are running in development mode, as we have found the pyproject.toml file
__version__ = tomllib.loads(_build_script.read_text())["tool"]["poetry"]["version"]

else:
# Load metadata from installed package information
_pkg_name: str = __package__ or __name__.split(".", maxsplit=1)[0]
__version__ = importlib.metadata.version(_pkg_name)
8 changes: 0 additions & 8 deletions fastboot/settings.py → fastboot/config.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import os
import pathlib
from abc import ABCMeta
from collections.abc import Callable
from typing import Any, Final

PROJECT_ROOT: pathlib.Path = pathlib.Path(__file__).parents[1]
PROJECT_CONFIG_TOML: pathlib.Path = PROJECT_ROOT / "pyproject.toml"

DEVELOP: bool = PROJECT_CONFIG_TOML.exists()

# ---------------------------------------------------------------------------------

PREF_DEF_REGISTRY: list[type["Preference"]] = []


Expand Down
25 changes: 0 additions & 25 deletions fastboot/version.py

This file was deleted.

12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/test_settings.py → tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from fastboot.settings import PREF_DEF_REGISTRY, AppPreferences, Preference
from fastboot.config import PREF_DEF_REGISTRY, AppPreferences, Preference

# ---------------------------
# Module Level Setup/TearDown
Expand Down
15 changes: 8 additions & 7 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import re

import fastboot
from fastboot import __version__ as version

SEMANTIC_VERSION_REGEX = re.compile(
SEMANTIC_VERSION_REGEX: re.Pattern[str] = re.compile(
"^([0-9]+)\\.([0-9]+)\\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z-]+)?$"
)


def test_version_info_present() -> None:
assert fastboot.__version__ is not None, "Missing application version information"
def test_version_info_available() -> None:
# Checks if the version string is defined
assert version is not None, "Missing application version information"


def test_version_info_follows_semantic_version_spec() -> None:
assert SEMANTIC_VERSION_REGEX.match(
fastboot.__version__
), "Application version number does not follow the semantic version specification"
# Checks if the version string follows semantic versioning
follows_semver_spec: bool = SEMANTIC_VERSION_REGEX.match(version) is not None
assert follows_semver_spec, "Application version number does not follow the semantic version specification"

0 comments on commit 93db292

Please sign in to comment.