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
Binary file modified .coverage
Binary file not shown.
229 changes: 217 additions & 12 deletions poetry.lock

Large diffs are not rendered by default.

71 changes: 39 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "change-me"
version = "0.0.1a"
version = "0.0.1"
description = "A simple Python template"
authors = ["Tsmorz <tonysmoragiewicz@gmail.com>"]
readme = "README.md"
package-mode = true

[tool.poetry.dependencies]
python = "^3.12"
python = "^3.11"
numpy = "^2.2.3"
pytest = "^8.3.5"
pytest-cov = "^6.0.0"
Expand All @@ -17,6 +17,13 @@ scipy = "^1.15.2"
tqdm = "^4.67.1"
poetry-core = "^2.1.2"

[tool.poetry.group.dev.dependencies]
ruff = "^0.6.9"
mypy = "^1.11"
pytest = "^8.3"
pytest-cov = "^6.0"
pandas-stubs = "^2.2"
scipy-stubs = "^1.11"

[build-system]
requires = ["poetry-core"]
Expand All @@ -28,41 +35,41 @@ line-length = 88

# Enable specific linting rules
lint.select = [
"E", # pycodestyle (style errors)
"F", # Pyflakes (logical errors)
"W", # Warnings
"C90", # mccabe (complexity checks)
"I", # isort (import sorting)
"N", # pep8-naming (naming conventions)
"D", # pydocstyle (docstring conventions)
"UP", # pyupgrade (Python syntax modernization)
"B", # flake8-bugbear (common pitfalls and performance issues)
"S", # flake8-bandit (security issues)
"YTT", # flake8-2020 (Python 2 compatibility issues)
"Q", # flake8-quotes (quote consistency)
"PL", # pylint (general best practices)
"RUF", # Ruff-specific rules
"E", # pycodestyle (style errors)
"F", # Pyflakes (logical errors)
"W", # Warnings
"C90", # mccabe (complexity checks)
"I", # isort (import sorting)
"N", # pep8-naming (naming conventions)
"D", # pydocstyle (docstring conventions)
"UP", # pyupgrade (Python syntax modernization)
"B", # flake8-bugbear (common pitfalls and performance issues)
"S", # flake8-bandit (security issues)
"YTT", # flake8-2020 (Python 2 compatibility issues)
"Q", # flake8-quotes (quote consistency)
"PL", # pylint (general best practices)
"RUF", # Ruff-specific rules
"T20",
"F841", # unused variable
"F841", # unused variable
"ERA001" # commented out code
]

# Exclude some noisy or unnecessary rules
lint.ignore = [
"D203", # 1 blank line before a class (conflicts with D211)
"D213", # Multi-line docstring should start on the first line (conflicts with D212)
"E501", # Line length (handled by autoformatter instead)
"N803", # Argument name should be lowercase
"N806", # Variable in function should be lowercase
"D415", # End first line with a period, question mark, or exclamation point
"S101", # Use of `assert` detected
"E203", # whitespace before ':'
"E731", # Do not assign a `lambda` expression, use a `def`
"D107", # Missing docstring in `__init__`
"D203", # 1 blank line before a class (conflicts with D211)
"D213", # Multi-line docstring should start on the first line (conflicts with D212)
"E501", # Line length (handled by autoformatter instead)
"N803", # Argument name should be lowercase
"N806", # Variable in function should be lowercase
"D415", # End first line with a period, question mark, or exclamation point
"S101", # Use of `assert` detected
"E203", # whitespace before ':'
"E731", # Do not assign a `lambda` expression, use a `def`
"D107", # Missing docstring in `__init__`
"PLR2004", # Magic value used in comparison
"S607", # Starting a process with a partial executable path
"S605", # Starting a process with a shell
"S603", # `subprocess` call: check for execution of untrusted input
"S607", # Starting a process with a partial executable path
"S605", # Starting a process with a shell
"S603", # `subprocess` call: check for execution of untrusted input
]

# Automatically fix issues where possible
Expand All @@ -75,7 +82,7 @@ combine-as-imports = true

# Enforce docstring styles
[tool.lint.pydocstyle]
convention = "google" # Options: "google", "numpy", "pep257"
convention = "google"

# Autoformatting options
[tool.ruff.format]
Expand All @@ -84,4 +91,4 @@ indent-style = "space" # Use spaces instead of tabs
line-ending = "lf" # Use LF for line endings (Unix standard)

[tool.poetry.urls]
homepage = "https://github.com/Tsmorz/template-python"
homepage = "https://github.com/TUM-Aries-Lab/template-python"
1 change: 0 additions & 1 deletion src/__init__.py

This file was deleted.

23 changes: 20 additions & 3 deletions src/change_me/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
from change_me.utils import setup_logger


def main(log_level: str = DEFAULT_LOG_LEVEL) -> None:
"""Run the pipeline."""
setup_logger(filename="log_file", log_dir=None, log_level=log_level)
def main(
log_level: str = DEFAULT_LOG_LEVEL, stderr_level: str = DEFAULT_LOG_LEVEL
) -> None:
"""Run the main pipeline.

:param log_level: The log level to use.
:param stderr_level: The std err level to use.
:return: None
"""
setup_logger(log_level=log_level, stderr_level=stderr_level)
logger.info("Hello, world!")


Expand All @@ -21,6 +28,16 @@ def main(log_level: str = DEFAULT_LOG_LEVEL) -> None:
default=DEFAULT_LOG_LEVEL,
choices=list(LogLevel()),
help="Set the log level.",
required=False,
type=str,
)
parser.add_argument(
"--stderr-level",
default=DEFAULT_LOG_LEVEL,
choices=list(LogLevel()),
help="Set the std err level.",
required=False,
type=str,
)
args = parser.parse_args()

Expand Down
1 change: 1 addition & 0 deletions src/change_me/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ def __iter__(self):


DEFAULT_LOG_LEVEL = LogLevel.info
DEFAULT_LOG_FILENAME = "log_file"
11 changes: 9 additions & 2 deletions src/change_me/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

from loguru import logger

from change_me.definitions import DATE_FORMAT, DEFAULT_LOG_LEVEL, ENCODING, LOG_DIR
from change_me.definitions import (
DATE_FORMAT,
DEFAULT_LOG_FILENAME,
DEFAULT_LOG_LEVEL,
ENCODING,
LOG_DIR,
)


def create_timestamped_filepath(suffix: str, output_dir: Path, prefix: str) -> Path:
Expand All @@ -25,7 +31,7 @@ def create_timestamped_filepath(suffix: str, output_dir: Path, prefix: str) -> P


def setup_logger(
filename: str,
filename: str = DEFAULT_LOG_FILENAME,
stderr_level: str = DEFAULT_LOG_LEVEL,
log_level: str = DEFAULT_LOG_LEVEL,
log_dir: Path | None = None,
Expand All @@ -49,4 +55,5 @@ def setup_logger(
)
logger.add(sys.stderr, level=stderr_level)
logger.add(filepath_with_time, level=log_level, encoding=ENCODING, enqueue=True)
logger.info(f"Logging to '{filepath_with_time}'.")
return filepath_with_time