Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- run: uv sync -q --no-default-groups --group test
- run: template sys-info --developer
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
- run: pytest tests --cov=template --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
if: ${{ github.repository == 'mscheltienne/template-python' }}
with:
Expand All @@ -63,7 +63,7 @@ jobs:
uv sync -q --no-default-groups --group test
uv pip install -q --upgrade --prerelease allow --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
- run: template sys-info --developer
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
- run: pytest tests --cov=template --cov-report=xml --cov-config=pyproject.toml
- uses: codecov/codecov-action@v5
if: ${{ github.repository == 'mscheltienne/template-python' }}
with:
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Template python repository. To bootstrap a project from this template, the
following steps are required:

- [ ] Rename the folder `template` to the package name
- [ ] Rename the folder `src/template` to the package name and update imports
- [ ] Edit `pyproject.toml` and all the `template` entries
- [ ] Edit the GitHub workflows in `.github`
- [ ] Enable `pre-commit.ci` on https://pre-commit.ci/
Expand Down
16 changes: 10 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ doc = [
]
ide = [
'ipykernel',
'ipympl',
'ipython',
]
style = [
Expand Down Expand Up @@ -99,14 +100,15 @@ branch = true
cover_pylib = false
omit = [
'**/__init__.py',
'**/conftest.py',
'**/template/_version.py',
'**/template/utils/_fixes.py',
'**/tests/**',
]

[tool.pytest.ini_options]
addopts = ['--color=yes', '--cov-report=', '--durations=20', '--junit-xml=junit-results.xml', '--strict-config', '--tb=short', '-ra', '-v']
filterwarnings = [
'error',
]
junit_family = 'xunit2'
minversion = '8.0'

Expand All @@ -120,7 +122,10 @@ line-ending = "lf"

[tool.ruff.lint]
ignore = []
select = ['A', 'B', 'C4', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PERF', 'PIE', 'PT', 'T20', 'UP', 'W']
select = ['A', 'B', 'C4', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PERF', 'PIE', 'PT', 'T20', 'TID', 'UP', 'W']

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.lint.per-file-ignores]
'*' = [
Expand All @@ -129,7 +134,6 @@ select = ['A', 'B', 'C4', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PERF', 'PIE',
'D104', # 'Missing docstring in public package'
'D107', # 'Missing docstring in __init__'
]
'*.pyi' = ['E501']
'__init__.py' = ['F401']
'tutorials/*' = ['D205', 'D400', 'T201']

Expand All @@ -141,11 +145,11 @@ ignore-decorators = ["template.utils._docs.copy_doc"]
include-package-data = false

[tool.setuptools.packages.find]
exclude = ['template*tests']
include = ['template*']
where = ['src']

[tool.setuptools_scm]
version_file = "template/_version.py"
version_file = "src/template/_version.py"
version_scheme = "release-branch-semver"

[tool.tomlsort]
Expand Down
4 changes: 4 additions & 0 deletions src/template/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from template import utils
from template._version import __version__
from template.utils.config import sys_info
from template.utils.logs import add_file_handler, set_log_level
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import click

from .sys_info import run as sys_info
from template._commands.sys_info import run as sys_info


@click.group()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import click

from .. import sys_info
from template.utils.config import sys_info


@click.command(name="sys-info")
Expand Down
3 changes: 3 additions & 0 deletions src/template/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Utilities module."""

from template.utils import config, logs
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 9 additions & 2 deletions template/utils/config.py → src/template/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import psutil
from packaging.requirements import Requirement

from ._checks import check_type
from template.utils._checks import check_type

if TYPE_CHECKING:
from collections.abc import Callable
Expand Down Expand Up @@ -110,7 +110,14 @@ def sys_info(
pyproject_data = tomllib.load(fid)
dependency_groups = pyproject_data.get("dependency-groups", {})
for key in sorted(dependency_groups):
dependencies = [Requirement(dep) for dep in dependency_groups[key]]
# Skip include-group references (dicts), only parse string dependencies
dependencies = [
Requirement(dep)
for dep in dependency_groups[key]
if isinstance(dep, str)
]
if len(dependencies) == 0:
continue
out(f"\nDeveloper '{key}' dependencies\n")
_list_dependencies_info(out, ljust, package, dependencies)

Expand Down
4 changes: 2 additions & 2 deletions template/utils/logs.py → src/template/utils/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from typing import TYPE_CHECKING
from warnings import warn_explicit

from ._checks import ensure_verbose
from ._fixes import WrapStdOut
from template.utils._checks import ensure_verbose
from template.utils._fixes import WrapStdOut

if TYPE_CHECKING:
from collections.abc import Callable
Expand Down
4 changes: 0 additions & 4 deletions template/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions template/conftest.py

This file was deleted.

3 changes: 0 additions & 3 deletions template/utils/__init__.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from click.testing import CliRunner

from ..main import run
from template._commands.main import run


def test_main() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from click.testing import CliRunner

from ..sys_info import run
from template._commands.sys_info import run


@pytest.mark.parametrize("developer", [False, True])
Expand Down
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from template.utils.logs import logger

if TYPE_CHECKING:
import pytest


def pytest_configure(config: pytest.Config) -> None:
"""Configure pytest options."""
logger.propagate = True # setup logging
Empty file added tests/utils/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
import numpy as np
import pytest

from .._checks import check_type, check_value, ensure_int, ensure_path, ensure_verbose
from template.utils._checks import (
check_type,
check_value,
ensure_int,
ensure_path,
ensure_verbose,
)


def test_ensure_int() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from ..config import _get_gpu_info, sys_info
from template.utils.config import _get_gpu_info, sys_info


def test_sys_info() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from .._docs import copy_doc
from ..logs import verbose
from template.utils._docs import copy_doc
from template.utils.logs import verbose


def test_copy_doc_function() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from .._imports import import_optional_dependency
from template.utils._imports import import_optional_dependency


def test_import_optional_dependency() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from ..logs import _use_log_level, add_file_handler, logger, verbose, warn
from template.utils.logs import _use_log_level, add_file_handler, logger, verbose, warn

if TYPE_CHECKING:
from pathlib import Path
Expand Down
Loading