Skip to content

Commit 50cb741

Browse files
authored
V6.0.2 (#25)
* V6.0.2 * V6.0.2 * V6.0.2 * V6.0.2 * V6.0.2 * V6.0.2 * V6.0.2 * V6.0.2 * V6.0.2 * V6.0.2 --------- Co-authored-by: ddc <ddc@users.noreply.github.com>
1 parent 707d98f commit 50cb741

39 files changed

+874
-725
lines changed

.github/PULL_REQUEST_TEMPLATE

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<!-- What is this pull request for? Does it fix any issues? -->
44

55
## Checklist
6-
- [ ] If code changes were made, then they have been tested.
7-
- [ ] I have updated the documentation to reflect the changes.
8-
- [ ] I have thought about how this code may affect other services.
9-
- [ ] This PR fixes an issue.
10-
- [ ] This PR add/remove/change unit tests.
11-
- [ ] This PR adds something new (e.g. new method or parameters).
12-
- [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
13-
- [ ] This PR is **not** a code change (e.g. documentation, README, ...)
6+
- [ ] If code changes were made, then they have been tested
7+
- [ ] I have updated the documentation to reflect any changes made
8+
- [ ] I have thought about how this code may affect other services
9+
- [ ] This PR fixes an issue
10+
- [ ] This PR is a breaking change (e.g. method, parameters, env variables)
11+
- [ ] This PR adds something new (e.g. method, parameters, env variables)
12+
- [ ] This PR change unit and integration tests
13+
- [ ] This PR is **NOT** a code change (e.g. documentation, packages)
1414

1515
## Reviewer
16-
- [ ] I understand that approving this code, I am also responsible for it going into the codebase.
16+
- [ ] I understand that approving this code, I am also responsible for it going into the codebase

.github/workflows/workflow.yml

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
name: CI/CD Pipeline
22

33
'on':
4+
pull_request:
45
push:
5-
branches: ['**']
66
tags: ['v*']
77

8+
env:
9+
LATEST_PYTHON_VERSION: '3.14'
810

911
jobs:
12+
lint:
13+
name: Lint (ruff)
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
- uses: astral-sh/ruff-action@v3
18+
with:
19+
args: "check"
20+
1021
test:
1122
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
12-
runs-on: ${{ matrix.runs-on || matrix.os }}
23+
runs-on: ${{ matrix.os }}
24+
needs: lint
1325
strategy:
1426
fail-fast: false
1527
matrix:
16-
os: ['ubuntu-latest', 'macos-latest', 'macos-14-arm64', 'windows-latest']
17-
python-version: ['3.12', '3.13', '3.14']
18-
include:
19-
- os: 'macos-14-arm64'
20-
runs-on: 'macos-14'
28+
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
29+
python-version: ['3.11', '3.14']
2130
defaults:
2231
run:
2332
working-directory: ${{ github.workspace }}
@@ -26,62 +35,70 @@ jobs:
2635

2736
- name: Install uv
2837
uses: astral-sh/setup-uv@v7
38+
with:
39+
enable-cache: true
2940

3041
- name: Set up Python ${{ matrix.python-version }}
3142
run: uv python install ${{ matrix.python-version }}
3243

3344
- name: Install dependencies
34-
run: uv sync --all-extras
45+
run: uv sync --locked --all-extras --dev
3546
shell: bash
3647

3748
- name: Run tests with coverage
3849
uses: nick-fields/retry@v3
3950
with:
4051
timeout_minutes: 2
4152
max_attempts: 3
42-
command: uv run pytest
53+
command: uv run --no-sync pytest
4354
shell: bash
4455

4556
- name: Upload coverage to Codecov
46-
if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest'
57+
if: matrix.python-version == env.LATEST_PYTHON_VERSION && matrix.os == 'ubuntu-latest'
4758
uses: codecov/codecov-action@v5
4859

4960
- name: Upload test results to Codecov
50-
if: matrix.python-version == '3.14' && matrix.os == 'ubuntu-latest'
61+
if: matrix.python-version == env.LATEST_PYTHON_VERSION && matrix.os == 'ubuntu-latest'
5162
uses: codecov/codecov-action@v5
5263
with:
5364
report_type: test_results
5465

55-
5666
build:
57-
name: Build package
67+
name: Build Package
5868
runs-on: ubuntu-latest
59-
needs: [test]
69+
needs: test
6070
if: startsWith(github.ref, 'refs/tags/v')
6171
steps:
6272
- uses: actions/checkout@v6
6373

6474
- name: Install uv
6575
uses: astral-sh/setup-uv@v7
76+
with:
77+
enable-cache: true
6678

67-
- name: Set up Python 3.14
68-
run: uv python install 3.14
79+
- name: Set up Python ${{ env.LATEST_PYTHON_VERSION }}
80+
run: uv python install ${{ env.LATEST_PYTHON_VERSION }}
6981

7082
- name: Build package
7183
run: uv build
7284

85+
- name: Smoke test (wheel)
86+
run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
87+
88+
- name: Smoke test (sdist)
89+
run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
90+
7391
- name: Upload artifacts
7492
uses: actions/upload-artifact@v6
7593
with:
7694
name: python-packages
7795
path: dist/
7896
retention-days: 7
7997

80-
8198
release:
8299
name: Create Release
83100
runs-on: ubuntu-latest
84-
needs: [build]
101+
needs: build
85102
if: startsWith(github.ref, 'refs/tags/v')
86103
permissions:
87104
contents: write

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/uv-pre-commit
3+
rev: 0.10.0
4+
hooks:
5+
- id: uv-lock

README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<a href="https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ"><img src="https://img.shields.io/badge/Donate-PayPal-brightgreen.svg?style=plastic" alt="Donate"/></a>
99
<a href="https://github.com/sponsors/ddc"><img src="https://img.shields.io/static/v1?style=plastic&label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=ff69b4" alt="Sponsor"/></a>
1010
<br>
11+
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=plastic" alt="Code style: black"/></a>
1112
<a href="https://github.com/astral-sh/uv"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json?style=plastic" alt="uv"/></a>
1213
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json?style=plastic" alt="Ruff"/></a>
13-
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=plastic" alt="Code style: black"/></a>
1414
<br>
1515
<a href="https://www.python.org/downloads"><img src="https://img.shields.io/pypi/pyversions/pythonLogs.svg?style=plastic&logo=python&cacheSeconds=3600" alt="Python"/></a>
1616
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=plastic" alt="License: MIT"/></a>
@@ -41,7 +41,9 @@
4141
- [Settings Cache Management](#settings-cache-management)
4242
- [Flexible Configuration Options](#flexible-configuration-options)
4343
- [Development](#development)
44-
- [Create DEV Environment, Running Tests and Building Wheel](#create-dev-environment-running-tests-and-building-wheel)
44+
- [Create DEV Environment and Running Tests](#create-dev-environment-and-running-tests)
45+
- [Update DEV Environment Packages](#update-dev-environment-packages)
46+
- [Building Wheel](#building-wheel)
4547
- [Optionals](#optionals)
4648
- [License](#license)
4749
- [Support](#support)
@@ -349,20 +351,34 @@ RotateWhen.MONDAY # "W0"
349351

350352
# Development
351353

352-
Must have [UV](https://uv.run/docs/getting-started/installation),
353-
[Black](https://black.readthedocs.io/en/stable/getting_started.html),
354-
[Ruff](https://docs.astral.sh/ruff/installation/), and
355-
[Poe the Poet](https://poethepoet.naber.dev/installation) installed.
354+
Must have [UV](https://uv.run/docs/getting-started/installation) installed.
356355

357-
## Create DEV Environment, Running Tests and Building Wheel
356+
## Create DEV Environment and Running Tests
357+
358+
> **Note:** All poe tasks automatically run ruff linter along with Black formatting
358359
359360
```shell
360-
uv sync --all-extras
361-
poe linter
361+
uv sync --all-extras --all-groups
362362
poe test
363+
```
364+
365+
366+
## Update DEV Environment Packages
367+
This will update all packages dependencies
368+
369+
```shell
370+
poe updatedev
371+
```
372+
373+
374+
## Building Wheel
375+
This will update all packages, run linter, both unit and integration tests and finally build the wheel
376+
377+
```shell
363378
poe build
364379
```
365380

381+
366382
## Optionals
367383

368384
### Create a cprofile.prof file from unit tests

pyproject.toml

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,31 @@
22
requires = ["hatchling"]
33
build-backend = "hatchling.build"
44

5+
[tool.hatch.metadata]
6+
allow-direct-references = true
7+
8+
[tool.hatch.build]
9+
include = ["pythonLogs/**/*"]
10+
11+
[tool.hatch.build.targets.wheel]
12+
packages = ["pythonLogs"]
13+
514
[project]
615
name = "pythonLogs"
7-
version = "6.0.1"
16+
version = "6.0.2"
817
description = "High-performance Python logging library with file rotation and optimized caching for better performance"
18+
urls.Repository = "https://github.com/ddc/pythonLogs"
19+
urls.Homepage = "https://pypi.org/project/pythonLogs"
920
license = {text = "MIT"}
1021
readme = "README.md"
11-
authors = [{name = "Daniel Costa", email = "danieldcsta@gmail.com"}]
12-
maintainers = [{name = "Daniel Costa"}]
22+
authors = [
23+
{name = "Daniel Costa", email = "danieldcsta@gmail.com"},
24+
]
25+
maintainers = [
26+
{name = "Daniel Costa"},
27+
]
1328
keywords = [
14-
"python3", "python-3", "python",
29+
"python", "python3", "python-3",
1530
"log", "logging", "logger",
1631
"logutils", "log-utils", "pythonLogs"
1732
]
@@ -20,6 +35,7 @@ classifiers = [
2035
"Development Status :: 5 - Production/Stable",
2136
"License :: OSI Approved :: MIT License",
2237
"Programming Language :: Python :: 3",
38+
"Programming Language :: Python :: 3.11",
2339
"Programming Language :: Python :: 3.12",
2440
"Programming Language :: Python :: 3.13",
2541
"Programming Language :: Python :: 3.14",
@@ -28,52 +44,44 @@ classifiers = [
2844
"Intended Audience :: Developers",
2945
"Natural Language :: English",
3046
]
31-
requires-python = ">=3.12"
47+
requires-python = ">=3.11"
3248
dependencies = [
3349
"pydantic-settings>=2.11.0",
3450
]
3551

36-
[project.urls]
37-
Homepage = "https://pypi.org/project/pythonLogs"
38-
Repository = "https://github.com/ddc/pythonLogs"
39-
40-
[project.optional-dependencies]
41-
test = [
42-
"poethepoet>=0.40.0",
52+
[dependency-groups]
53+
dev = [
4354
"psutil>=7.2.2",
44-
"pytest>=9.0.2",
4555
"pytest-cov>=7.0.0",
56+
"poethepoet>=0.41.0",
57+
"ruff>=0.15.0",
58+
"black>=26.1.0",
4659
]
4760

48-
[tool.hatch.build]
49-
include = ["pythonLogs/**/*"]
50-
51-
[tool.hatch.build.targets.wheel]
52-
packages = ["pythonLogs"]
53-
5461
[tool.poe.tasks]
55-
build = "uv build --wheel"
56-
updatedev.shell = "uv lock && uv sync --no-install-project --all-extras"
5762
linter.shell = "uv run ruff check --fix . && uv run black ."
58-
profile = "uv run python -m cProfile -o cprofile.prof -m pytest"
59-
test = "uv run pytest"
63+
profile.sequence = ["linter", {shell = "uv run python -m cProfile -o cprofile_unit.prof -m pytest --no-cov"}]
64+
test.sequence = ["linter", {shell = "uv run pytest"}]
65+
updatedev.sequence = ["linter", {shell = "uv lock --upgrade && uv sync --all-extras --group dev"}]
66+
build.sequence = ["updatedev", "test", {shell = "uv build --wheel"}]
6067

6168
[tool.pytest.ini_options]
6269
addopts = "-v --cov --cov-report=term --cov-report=xml --junitxml=junit.xml"
6370
junit_family = "legacy"
6471
testpaths = ["tests"]
6572
markers = [
66-
"slow: marks tests as slow (deselect with '-m \"not slow\"')"
73+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
6774
]
6875

6976
[tool.coverage.run]
7077
omit = [
7178
"tests/*",
7279
"*/__init__.py",
73-
"*/_version.py",
7480
]
7581

7682
[tool.coverage.report]
83+
show_missing = true
84+
skip_covered = false
7785
exclude_lines = [
7886
"pragma: no cover",
7987
"def __repr__",
@@ -86,31 +94,25 @@ exclude_lines = [
8694
"class .*\\bProtocol\\):",
8795
"@(abc\\.)?abstractmethod",
8896
]
89-
show_missing = true
90-
skip_covered = false
9197

9298
[tool.black]
9399
line-length = 120
94100
skip-string-normalization = true
95101

96102
[tool.ruff]
97103
line-length = 120
104+
target-version = "py311"
98105

99106
[tool.ruff.lint]
100-
# I - Import sorting and organization
101-
# F401 - Detect and remove unused imports
102-
select = ["I", "F401"]
107+
select = ["E", "W", "F", "I", "B", "C4", "UP"]
108+
ignore = ["E501", "E402", "UP046", "UP047"]
109+
110+
[tool.ruff.lint.per-file-ignores]
111+
"__init__.py" = ["F401"]
112+
"tests/**/*.py" = ["S101", "S105", "S106", "S311", "SLF001", "F841"]
103113

104114
[tool.ruff.lint.isort]
105115
known-first-party = ["pythonLogs"]
106116
force-sort-within-sections = false
107117
from-first = false
108118
no-sections = true
109-
110-
[tool.ruff.lint.per-file-ignores]
111-
# S101 Use of `assert` detected
112-
# S105 Possible hardcoded password assigned to variable
113-
# S106 Possible hardcoded password assigned to argument
114-
# S311 Standard pseudo-random generators are not suitable for cryptographic purposes
115-
# SLF001 Private member accessed
116-
"tests/**/*.py" = ["S101", "S105", "S106", "S311", "SLF001"]

pythonLogs/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LOG_STREAM_HANDLER=True
1515
LOG_SHOW_LOCATION=False
1616
# Memory Management Settings
1717
LOG_MAX_LOGGERS=50
18+
LOG_MAX_FORMATTERS=50
1819
LOG_LOGGER_TTL_SECONDS=1800
1920

2021
# SizeRotatingLog Settings (only needed when using SizeRotatingLog)

pythonLogs/basic_log.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pythonLogs.core.thread_safety import auto_thread_safe
66

77

8-
@auto_thread_safe(['init'])
8+
@auto_thread_safe(["init"])
99
class BasicLog:
1010
"""Basic logger with context manager support for automatic resource cleanup."""
1111

@@ -48,13 +48,13 @@ def init(self):
4848

4949
def __enter__(self):
5050
"""Context manager entry."""
51-
if not hasattr(self, 'logger') or self.logger is None:
51+
if not hasattr(self, "logger") or self.logger is None:
5252
self.init()
5353
return self.logger
5454

5555
def __exit__(self, exc_type, exc_val, exc_tb):
5656
"""Context manager exit with automatic cleanup."""
57-
if hasattr(self, 'logger'):
57+
if hasattr(self, "logger"):
5858
cleanup_logger_handlers(self.logger)
5959

6060
@staticmethod

0 commit comments

Comments
 (0)