Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JoFrhwld committed Nov 9, 2024
2 parents 24f0b10 + d778a24 commit f2b3c2d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
14 changes: 13 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ scipy = "^1.13.1"
cloudpickle = "^3.0.0"
nptyping = "^2.5.0"
librosa = "^0.10.2.post1"
toml = "^0.10.2"


[tool.poetry.group.docs.dependencies]
Expand Down
13 changes: 11 additions & 2 deletions src/new_fave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@

from importlib.metadata import version

# this is bugged for testing
#__version__ = version("new_fave")
from pathlib import Path
import toml

__version__ = "unknown"
# adopt path to your pyproject.toml
pyproject_toml_file = Path(__file__).parent.parent.parent / "pyproject.toml"
if pyproject_toml_file.exists() and pyproject_toml_file.is_file():
data = toml.load(pyproject_toml_file)
# check project.version
if "tool" in data and "poetry" in data["tool"] and "version" in data["tool"]["poetry"]:
__version__ = data["tool"]["poetry"]["version"]

__all__ = [
"VowelMeasurement",
Expand Down
2 changes: 1 addition & 1 deletion src/new_fave/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
def ask(message: str) -> bool:
response = click.confirm(
f"{message}",
default=True
default=False
)
return response

Expand Down
18 changes: 18 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pathlib import Path
import toml
import new_fave

def test_version():
pyproject_toml_file = Path(__file__).parent.parent / "pyproject.toml"
toml_v = "unknown"
if pyproject_toml_file.exists() and pyproject_toml_file.is_file():
data = toml.load(pyproject_toml_file)
# check project.version
if "project" in data and "version" in data["project"]:
toml_v = data["project"]["version"]
# check tool.poetry.version
elif "tool" in data and "poetry" in data["tool"] and "version" in data["tool"]["poetry"]:
toml_v = data["tool"]["poetry"]["version"]

assert new_fave.__version__ == toml_v

0 comments on commit f2b3c2d

Please sign in to comment.