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
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,54 @@ dev = [

[tool.hatch.build.targets.wheel]
packages = ["src"]

[tool.ruff]
line-length = 88
target-version = "py39"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"TID", # flake8-tidy-imports
"E402", # module-import-not-at-top-of-file
"N", # pep8-naming
"S", # flake8-bandit
"PTH", # flake8-use-pathlib
"RUF", # ruff-specific rules
"ICN", # flake8-import-conventions
]

ignore = [
"E501", # line too long (handled by line-length)
"TID252", # prefer absolute imports (keep relative for internal imports)
"S101", # assert used (acceptable in tests)
]

[tool.ruff.lint.flake8-tidy-imports]
# Prevent specific problematic imports
banned-api = {}

[tool.ruff.lint.isort]
known-first-party = ["python-collab-template"]

[tool.mypy]
python_version = "3.9"
strict = true
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true
4 changes: 4 additions & 0 deletions scripts/init_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ def main() -> None:
if "tool" in config and "hatch" in config["tool"] and "build" in config["tool"]["hatch"] and "targets" in config["tool"]["hatch"]["build"] and "wheel" in config["tool"]["hatch"]["build"]["targets"]:
config["tool"]["hatch"]["build"]["targets"]["wheel"]["packages"] = [project_module_name]

# Update ruff known-first-party if ruff config exists
if "tool" in config and "ruff" in config["tool"] and "lint" in config["tool"]["ruff"] and "isort" in config["tool"]["ruff"]["lint"]:
config["tool"]["ruff"]["lint"]["isort"]["known-first-party"] = [project_module_name]

with open(pyproject_path, "wb") as f:
tomli_w.dump(config, f)

Expand Down
6 changes: 3 additions & 3 deletions src/example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List, Optional
import statistics
from dataclasses import dataclass
from datetime import datetime
from typing import Optional


@dataclass
Expand All @@ -14,8 +14,8 @@ class DataPoint:


def calculate_moving_average(
data: List[DataPoint], window_size: int = 3
) -> List[float]:
data: list[DataPoint], window_size: int = 3
) -> list[float]:
"""Calculate moving average of values.

Args:
Expand Down