Skip to content

Commit 18bfa81

Browse files
chore(deps): update dependencies and improve project configuration
1 parent 4e905c3 commit 18bfa81

File tree

6 files changed

+146
-192
lines changed

6 files changed

+146
-192
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changelog
22

3+
<!-- TODO @hasansezertasan: Conventional changelog should be optional. -->
34
All notable changes to this project will be documented in this file.
45

56
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

pyproject.toml

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,38 @@ projectname = "projectname.cli:app"
6262
[dependency-groups]
6363
dev = [
6464
"projectname[cli]",
65-
"tox>=4.25.0",
66-
"tox-uv>=1.13.1",
65+
"tox==4.31.0",
66+
"tox-uv==1.29.0",
6767
{ include-group = "lint" },
6868
{ include-group = "test" },
6969
{ include-group = "tool" },
7070
]
7171
lint = [
72-
"mypy>=1.18.2",
73-
"pyright>=1.1.406",
72+
"mypy==1.18.2",
73+
"pyright==1.1.406",
7474
"ty==0.0.1a23",
75-
"pyrefly==0.37.0",
76-
"ruff>=0.14.1",
77-
"taplo>=0.9.3",
78-
"typos>=1.38.1",
79-
"validate-pyproject[all]>=0.24.1",
80-
"vulture>=2.14",
81-
"slotscheck>=0.19.1",
75+
"pyrefly==0.38.1",
76+
"ruff==0.14.1",
77+
"taplo==0.9.3",
78+
"typos==1.38.1",
79+
"validate-pyproject[all]==0.24.1",
80+
"vulture==2.14",
81+
"slotscheck==0.19.1",
8282
]
8383
test = [
8484
"coverage-enable-subprocess==1.0",
85-
"coverage[toml]~=7.4",
86-
"pytest-dependency>=0.6.0",
87-
"pytest-mock~=3.12",
88-
"pytest-rerunfailures~=14.0",
89-
"pytest-xdist[psutil]~=3.5",
85+
"coverage[toml]==7.4",
86+
"pytest-dependency==0.6.0",
87+
"pytest-mock==3.12",
88+
"pytest-rerunfailures==16.1",
89+
"pytest-xdist[psutil]==3.5",
9090
"pytest==8.4.2",
9191
]
92-
tool = ["poethepoet==0.37.0", "pre-commit==4.3.0", "commitizen==4.9.1"]
92+
tool = [
93+
"pre-commit==4.3.0",
94+
"poethepoet==0.37.0",
95+
"commitizen==4.9.1",
96+
]
9397

9498

9599
[tool.uv]
@@ -98,6 +102,7 @@ cache-keys = [
98102
{ git = { commit = true, tags = true } },
99103
]
100104
trusted-publishing = "always"
105+
add-bounds = "exact"
101106

102107

103108
[build-system]
@@ -118,7 +123,7 @@ hooks.vcs.version-file = "src/projectname/_version.py"
118123
version_scheme = "only-version"
119124
local_scheme = "no-local-version"
120125

121-
126+
# TODO @hasansezertasan: Commitizen should be optional.
122127
[tool.commitizen]
123128
name = "cz_conventional_commits"
124129
version_provider = "scm"
@@ -192,39 +197,39 @@ preview = true
192197
select = ["ALL"]
193198

194199

195-
[tool.ruff.lint.per-file-ignores]
196-
"tests/*.py" = ['S101']
200+
# TODO @hasansezertasan: Update the author name and email
201+
[tool.ruff.lint.flake8-copyright]
202+
author = "Hasan Sezer Taşan <hasansezertasan@gmail.com>"
197203

198204

199-
[tool.ruff.lint.pyupgrade]
200-
keep-runtime-typing = true
205+
[tool.ruff.lint.flake8-tidy-imports]
206+
ban-relative-imports = "all"
207+
208+
209+
[tool.ruff.lint.mccabe]
210+
max-complexity = 5
201211

202212

203213
[tool.ruff.lint.pycodestyle]
204214
ignore-overlong-task-comments = true
205215

206216

207-
# TODO @hasansezertasan: Update the author name and email
208-
[tool.ruff.lint.flake8-copyright]
209-
author = "Hasan Sezer Taşan <hasansezertasan@gmail.com>"
217+
[tool.ruff.lint.pydocstyle]
218+
convention = "pep257"
210219

211220

212-
[tool.ruff.lint.flake8-tidy-imports]
213-
ban-relative-imports = "all"
221+
[tool.ruff.lint.per-file-ignores]
222+
"tests/*.py" = ['S101']
214223

215224

216-
[tool.ruff.lint.pydocstyle]
217-
convention = "pep257"
225+
[tool.ruff.lint.pyupgrade]
226+
keep-runtime-typing = true
218227

219228

220229
[tool.ruff.lint.ruff]
221230
parenthesize-tuple-in-subscript = true
222231

223232

224-
[tool.ruff.lint.mccabe]
225-
max-complexity = 5
226-
227-
228233
[tool.mypy]
229234
files = ["src"]
230235
pretty = true
@@ -255,6 +260,7 @@ python-version = "3.10"
255260
project-includes = ["src"]
256261

257262

263+
# TODO @hasansezertasan: poethepoet should be optional.
258264
[tool.poe]
259265
executor.type = "uv"
260266

@@ -326,6 +332,7 @@ description = "Run Linters and Formatters"
326332
allowlist_externals = ["actionlint", "yamlfmt"]
327333

328334

335+
# TODO @hasansezertasan: This should be available if the project is a CLI project.
329336
[tool.tox.env.run]
330337
commands = [["projectname", "version", { replace = "posargs", extend = true }]]
331338
description = "Run the application"

src/projectname/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
from __future__ import annotations
55

66
import platform
7-
from importlib.metadata import version
7+
from importlib.metadata import Distribution
88

99
import typer
1010

11+
from projectname.config import PROJECT_NAME
1112
from projectname.logging_setup import logger
1213

1314
app = typer.Typer(
@@ -26,8 +27,9 @@ def show_version() -> None:
2627
Example output:
2728
0.1.0
2829
"""
30+
distribution = Distribution.from_name(PROJECT_NAME)
2931
logger.info("Command `version` called.")
30-
typer.echo(version("projectname"))
32+
typer.echo(distribution.version)
3133
logger.info("Version displayed successfully.")
3234

3335

@@ -43,10 +45,11 @@ def info() -> None:
4345
Python Version: 3.8.20 (CPython)
4446
Platform: Darwin
4547
"""
48+
distribution = Distribution.from_name(PROJECT_NAME)
4649
logger.info("Command `info` called.")
4750
python_version = platform.python_version()
4851
python_implementation = platform.python_implementation()
49-
typer.echo(f"Application Version: {version('projectname')}")
52+
typer.echo(f"Application Version: {distribution.version}")
5053
typer.echo(f"Python Version: {python_version} ({python_implementation})")
5154
typer.echo(f"Platform: {platform.system()}")
5255
logger.info("Application information displayed successfully.")

src/projectname/config.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
from pathlib import Path
44

5-
ROOT_FOLDER_NAME = ".projectname"
6-
DEFAULT_USER_HOME_CACHE_PATH = Path.home() / ROOT_FOLDER_NAME
7-
"""Path to the user home cache path."""
8-
9-
log_file_path: Path = DEFAULT_USER_HOME_CACHE_PATH / "projectname.log"
5+
PROJECT_NAME: str = "projectname"
6+
"""Name of the project."""
7+
ROOT_FOLDER_NAME: str = f".{PROJECT_NAME}"
8+
"""Name of the root folder."""
9+
ROOT_FOLDER_PATH: Path = Path.home() / ROOT_FOLDER_NAME
10+
"""Path to the root folder."""
11+
LOG_FILE_PATH: Path = ROOT_FOLDER_PATH / "main.log"
1012
"""Path to the log file."""
13+
CONFIG_FILE_PATH: Path = ROOT_FOLDER_PATH / "config.json"
14+
"""Path to the config file."""

src/projectname/logging_setup.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,29 @@
1313
import sys
1414
from logging.handlers import RotatingFileHandler
1515

16-
from projectname.config import DEFAULT_USER_HOME_CACHE_PATH, log_file_path
16+
from projectname.config import ROOT_FOLDER_PATH, LOG_FILE_PATH, PROJECT_NAME
1717

1818

1919
def setup_logger() -> logging.Logger:
20-
"""Set up and return the main logger for the projectname application.
20+
"""Set up and return the main logger for the keycast application.
2121
2222
Ensures that handlers are only added once to avoid duplicate log entries
2323
if this module is imported multiple times.
2424
2525
Returns:
26-
logging.Logger: Configured logger for the projectname application.
27-
26+
logging.Logger: Configured logger for the keycast application.
2827
"""
29-
logger_ = logging.getLogger("projectname")
28+
logger_ = logging.getLogger(PROJECT_NAME)
3029
logger_.setLevel(logging.INFO)
3130

3231
# Only add handlers if they haven't been added yet
3332
if not logger_.handlers:
3433
# Ensure the log file exists
35-
DEFAULT_USER_HOME_CACHE_PATH.mkdir(parents=True, exist_ok=True)
34+
ROOT_FOLDER_PATH.mkdir(parents=True, exist_ok=True)
3635

3736
# Create a file handler that logs all messages
3837
file_handler = RotatingFileHandler(
39-
log_file_path, maxBytes=10 * 1024 * 1024, backupCount=5
38+
LOG_FILE_PATH, maxBytes=10 * 1024 * 1024, backupCount=5
4039
)
4140
file_handler.setLevel(logging.INFO)
4241

0 commit comments

Comments
 (0)