tmpkit 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tmpkit-1.0.0/.github/FUNDING.yml +3 -0
- tmpkit-1.0.0/.github/ISSUE_TEMPLATE/bug_report.yml +82 -0
- tmpkit-1.0.0/.github/ISSUE_TEMPLATE/config.yml +8 -0
- tmpkit-1.0.0/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
- tmpkit-1.0.0/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- tmpkit-1.0.0/.github/dependabot.yml +27 -0
- tmpkit-1.0.0/.github/workflows/ci.yml +52 -0
- tmpkit-1.0.0/.github/workflows/release.yml +99 -0
- tmpkit-1.0.0/.gitignore +36 -0
- tmpkit-1.0.0/.pre-commit-config.yaml +13 -0
- tmpkit-1.0.0/CHANGELOG.md +103 -0
- tmpkit-1.0.0/CODE_OF_CONDUCT.md +128 -0
- tmpkit-1.0.0/CONTRIBUTING.md +126 -0
- tmpkit-1.0.0/LICENSE +21 -0
- tmpkit-1.0.0/PKG-INFO +506 -0
- tmpkit-1.0.0/README.md +473 -0
- tmpkit-1.0.0/SECURITY.md +31 -0
- tmpkit-1.0.0/pyproject.toml +94 -0
- tmpkit-1.0.0/tests/conftest.py +26 -0
- tmpkit-1.0.0/tests/e2e/test_real_cleanup.py +126 -0
- tmpkit-1.0.0/tests/integration/test_concurrent.py +111 -0
- tmpkit-1.0.0/tests/integration/test_subprocess.py +79 -0
- tmpkit-1.0.0/tests/unit/test_async_dir.py +139 -0
- tmpkit-1.0.0/tests/unit/test_async_file.py +231 -0
- tmpkit-1.0.0/tests/unit/test_atomic.py +482 -0
- tmpkit-1.0.0/tests/unit/test_config.py +87 -0
- tmpkit-1.0.0/tests/unit/test_decorators.py +334 -0
- tmpkit-1.0.0/tests/unit/test_error_paths.py +937 -0
- tmpkit-1.0.0/tests/unit/test_keep.py +304 -0
- tmpkit-1.0.0/tests/unit/test_registry.py +581 -0
- tmpkit-1.0.0/tests/unit/test_smoke.py +7 -0
- tmpkit-1.0.0/tests/unit/test_sync_dir.py +229 -0
- tmpkit-1.0.0/tests/unit/test_sync_file.py +443 -0
- tmpkit-1.0.0/tests/unit/test_types.py +68 -0
- tmpkit-1.0.0/tests/unit/test_windows.py +199 -0
- tmpkit-1.0.0/tmpkit/__init__.py +24 -0
- tmpkit-1.0.0/tmpkit/_async.py +293 -0
- tmpkit-1.0.0/tmpkit/_atomic.py +289 -0
- tmpkit-1.0.0/tmpkit/_config.py +32 -0
- tmpkit-1.0.0/tmpkit/_decorators.py +271 -0
- tmpkit-1.0.0/tmpkit/_registry.py +159 -0
- tmpkit-1.0.0/tmpkit/_sync.py +565 -0
- tmpkit-1.0.0/tmpkit/_types.py +42 -0
- tmpkit-1.0.0/tmpkit/py.typed +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug or unexpected behavior
|
|
3
|
+
title: "[bug] "
|
|
4
|
+
labels: ["bug", "triage"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for taking the time to file a bug report! Please fill out the information below.
|
|
10
|
+
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: description
|
|
13
|
+
attributes:
|
|
14
|
+
label: Description
|
|
15
|
+
description: A clear description of the bug.
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: reproduction
|
|
21
|
+
attributes:
|
|
22
|
+
label: Minimal Reproduction
|
|
23
|
+
description: |
|
|
24
|
+
The smallest code snippet that reproduces the bug.
|
|
25
|
+
value: |
|
|
26
|
+
```python
|
|
27
|
+
from tmpkit import temp_file
|
|
28
|
+
|
|
29
|
+
# ... your code here
|
|
30
|
+
```
|
|
31
|
+
validations:
|
|
32
|
+
required: true
|
|
33
|
+
|
|
34
|
+
- type: textarea
|
|
35
|
+
id: expected
|
|
36
|
+
attributes:
|
|
37
|
+
label: Expected Behavior
|
|
38
|
+
description: What you expected to happen.
|
|
39
|
+
validations:
|
|
40
|
+
required: true
|
|
41
|
+
|
|
42
|
+
- type: textarea
|
|
43
|
+
id: actual
|
|
44
|
+
attributes:
|
|
45
|
+
label: Actual Behavior
|
|
46
|
+
description: What actually happened. Include full traceback if applicable.
|
|
47
|
+
validations:
|
|
48
|
+
required: true
|
|
49
|
+
|
|
50
|
+
- type: input
|
|
51
|
+
id: python-version
|
|
52
|
+
attributes:
|
|
53
|
+
label: Python Version
|
|
54
|
+
placeholder: "3.13"
|
|
55
|
+
validations:
|
|
56
|
+
required: true
|
|
57
|
+
|
|
58
|
+
- type: input
|
|
59
|
+
id: tmpkit-version
|
|
60
|
+
attributes:
|
|
61
|
+
label: tmpkit Version
|
|
62
|
+
placeholder: "0.1.0"
|
|
63
|
+
validations:
|
|
64
|
+
required: true
|
|
65
|
+
|
|
66
|
+
- type: dropdown
|
|
67
|
+
id: os
|
|
68
|
+
attributes:
|
|
69
|
+
label: Operating System
|
|
70
|
+
options:
|
|
71
|
+
- Linux
|
|
72
|
+
- macOS
|
|
73
|
+
- Windows
|
|
74
|
+
- Other
|
|
75
|
+
validations:
|
|
76
|
+
required: true
|
|
77
|
+
|
|
78
|
+
- type: textarea
|
|
79
|
+
id: additional
|
|
80
|
+
attributes:
|
|
81
|
+
label: Additional Context
|
|
82
|
+
description: Any other context, logs, or screenshots.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
blank_issues_enabled: false
|
|
2
|
+
contact_links:
|
|
3
|
+
- name: Discussion
|
|
4
|
+
url: https://github.com/MathiasPaulenko/tmpkit/discussions
|
|
5
|
+
about: Ask questions and discuss ideas with the community
|
|
6
|
+
- name: Security Report
|
|
7
|
+
url: https://github.com/MathiasPaulenko/tmpkit/security/policy
|
|
8
|
+
about: Report security vulnerabilities privately (do NOT open public issues)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest a new feature or enhancement
|
|
3
|
+
title: "[feat] "
|
|
4
|
+
labels: ["enhancement", "triage"]
|
|
5
|
+
body:
|
|
6
|
+
- type: markdown
|
|
7
|
+
attributes:
|
|
8
|
+
value: |
|
|
9
|
+
Thanks for suggesting a feature! Please describe your use case clearly.
|
|
10
|
+
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: problem
|
|
13
|
+
attributes:
|
|
14
|
+
label: Problem
|
|
15
|
+
description: What problem does this feature solve? What are you trying to do that tmpkit doesn't support?
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: solution
|
|
21
|
+
attributes:
|
|
22
|
+
label: Proposed Solution
|
|
23
|
+
description: Describe the API or behavior you'd like to see.
|
|
24
|
+
value: |
|
|
25
|
+
```python
|
|
26
|
+
from tmpkit import temp_file
|
|
27
|
+
|
|
28
|
+
# proposed usage
|
|
29
|
+
```
|
|
30
|
+
validations:
|
|
31
|
+
required: true
|
|
32
|
+
|
|
33
|
+
- type: textarea
|
|
34
|
+
id: alternatives
|
|
35
|
+
attributes:
|
|
36
|
+
label: Alternatives Considered
|
|
37
|
+
description: Have you considered workarounds or other approaches?
|
|
38
|
+
|
|
39
|
+
- type: textarea
|
|
40
|
+
id: additional
|
|
41
|
+
attributes:
|
|
42
|
+
label: Additional Context
|
|
43
|
+
description: Any other context, screenshots, or links.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
<!-- Brief description of what this PR does -->
|
|
4
|
+
|
|
5
|
+
## Type of Change
|
|
6
|
+
|
|
7
|
+
- [ ] Bug fix (non-breaking change which fixes an issue)
|
|
8
|
+
- [ ] New feature (non-breaking change which adds functionality)
|
|
9
|
+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
|
10
|
+
- [ ] Documentation update
|
|
11
|
+
- [ ] Refactor / cleanup
|
|
12
|
+
|
|
13
|
+
## Checklist
|
|
14
|
+
|
|
15
|
+
- [ ] Code follows the style guidelines (`ruff check` + `ruff format` pass)
|
|
16
|
+
- [ ] `mypy --strict` passes with no errors
|
|
17
|
+
- [ ] Tests added for new functionality / bug fix
|
|
18
|
+
- [ ] All tests pass (`pytest tests/ -v`)
|
|
19
|
+
- [ ] Coverage stays >= 95%
|
|
20
|
+
- [ ] `CHANGELOG.md` updated under `[Unreleased]`
|
|
21
|
+
- [ ] Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/)
|
|
22
|
+
|
|
23
|
+
## Related Issues
|
|
24
|
+
|
|
25
|
+
<!-- Link to issues: Closes #123, Refs #456 -->
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: pip
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: weekly
|
|
7
|
+
day: monday
|
|
8
|
+
open-pull-requests-limit: 5
|
|
9
|
+
labels:
|
|
10
|
+
- dependencies
|
|
11
|
+
- python
|
|
12
|
+
commit-message:
|
|
13
|
+
prefix: "chore"
|
|
14
|
+
include: scope
|
|
15
|
+
|
|
16
|
+
- package-ecosystem: github-actions
|
|
17
|
+
directory: /
|
|
18
|
+
schedule:
|
|
19
|
+
interval: weekly
|
|
20
|
+
day: monday
|
|
21
|
+
open-pull-requests-limit: 5
|
|
22
|
+
labels:
|
|
23
|
+
- dependencies
|
|
24
|
+
- github-actions
|
|
25
|
+
commit-message:
|
|
26
|
+
prefix: "chore"
|
|
27
|
+
include: scope
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.13"
|
|
20
|
+
- name: Install dev deps
|
|
21
|
+
run: pip install -e ".[dev]"
|
|
22
|
+
- name: Ruff check
|
|
23
|
+
run: ruff check tmpkit/ tests/
|
|
24
|
+
- name: Ruff format check
|
|
25
|
+
run: ruff format --check tmpkit/ tests/
|
|
26
|
+
- name: Mypy
|
|
27
|
+
run: mypy --strict tmpkit/
|
|
28
|
+
- name: Build check
|
|
29
|
+
run: python -m build --wheel
|
|
30
|
+
|
|
31
|
+
test:
|
|
32
|
+
strategy:
|
|
33
|
+
fail-fast: false
|
|
34
|
+
matrix:
|
|
35
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
36
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
37
|
+
runs-on: ${{ matrix.os }}
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/setup-python@v5
|
|
41
|
+
with:
|
|
42
|
+
python-version: ${{ matrix.python-version }}
|
|
43
|
+
- name: Install dev deps
|
|
44
|
+
run: pip install -e ".[dev]"
|
|
45
|
+
- name: Pytest
|
|
46
|
+
run: pytest --cov=tmpkit --cov-report=xml --cov-branch
|
|
47
|
+
- name: Upload coverage
|
|
48
|
+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
|
|
49
|
+
uses: codecov/codecov-action@v4
|
|
50
|
+
with:
|
|
51
|
+
files: ./coverage.xml
|
|
52
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.13"
|
|
21
|
+
- name: Install build
|
|
22
|
+
run: pip install build
|
|
23
|
+
- name: Build dist
|
|
24
|
+
run: python -m build
|
|
25
|
+
- name: Upload artifacts
|
|
26
|
+
uses: actions/upload-artifact@v4
|
|
27
|
+
with:
|
|
28
|
+
name: dist
|
|
29
|
+
path: dist/
|
|
30
|
+
|
|
31
|
+
publish-pypi:
|
|
32
|
+
needs: build
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
environment: pypi
|
|
35
|
+
permissions:
|
|
36
|
+
id-token: write
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/download-artifact@v4
|
|
39
|
+
with:
|
|
40
|
+
name: dist
|
|
41
|
+
path: dist/
|
|
42
|
+
- name: Publish to PyPI
|
|
43
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
44
|
+
|
|
45
|
+
publish-github-release:
|
|
46
|
+
needs: build
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
permissions:
|
|
49
|
+
contents: write
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
- uses: actions/download-artifact@v4
|
|
53
|
+
with:
|
|
54
|
+
name: dist
|
|
55
|
+
path: dist/
|
|
56
|
+
- name: Extract release notes
|
|
57
|
+
id: notes
|
|
58
|
+
run: |
|
|
59
|
+
TAG="${GITHUB_REF_NAME}"
|
|
60
|
+
VERSION="${TAG#v}"
|
|
61
|
+
python -c "
|
|
62
|
+
import re, sys
|
|
63
|
+
version = sys.argv[1]
|
|
64
|
+
text = open('CHANGELOG.md').read()
|
|
65
|
+
pattern = rf'## \[{re.escape(version)}\](.*?)(?=## \[|\Z)'
|
|
66
|
+
match = re.search(pattern, text, re.DOTALL)
|
|
67
|
+
print(match.group(1).strip() if match else 'Release ' + version)
|
|
68
|
+
" "$VERSION" > release_notes.md
|
|
69
|
+
- name: Detect prerelease
|
|
70
|
+
id: pre
|
|
71
|
+
run: |
|
|
72
|
+
if [[ "${GITHUB_REF_NAME}" =~ ^v0\. ]] || [[ "${GITHUB_REF_NAME}" =~ (a|b|rc)[0-9]+$ ]]; then
|
|
73
|
+
echo "prerelease=true" >> "$GITHUB_OUTPUT"
|
|
74
|
+
else
|
|
75
|
+
echo "prerelease=false" >> "$GITHUB_OUTPUT"
|
|
76
|
+
fi
|
|
77
|
+
- name: Create GitHub Release
|
|
78
|
+
env:
|
|
79
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
80
|
+
run: |
|
|
81
|
+
gh release create "${GITHUB_REF_NAME}" \
|
|
82
|
+
dist/*.whl dist/*.tar.gz \
|
|
83
|
+
--title "${GITHUB_REF_NAME}" \
|
|
84
|
+
--notes-file release_notes.md \
|
|
85
|
+
${{ steps.pre.outputs.prerelease == 'true' && '--prerelease' || '' }}
|
|
86
|
+
|
|
87
|
+
verify:
|
|
88
|
+
needs: publish-pypi
|
|
89
|
+
runs-on: ubuntu-latest
|
|
90
|
+
steps:
|
|
91
|
+
- uses: actions/setup-python@v5
|
|
92
|
+
with:
|
|
93
|
+
python-version: "3.13"
|
|
94
|
+
- name: Install from PyPI
|
|
95
|
+
run: |
|
|
96
|
+
VERSION="${GITHUB_REF_NAME#v}"
|
|
97
|
+
pip install "tmpkit==${VERSION}"
|
|
98
|
+
- name: Smoke test
|
|
99
|
+
run: python -c "from tmpkit import temp_file, temp_dir; print('ok')"
|
tmpkit-1.0.0/.gitignore
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
*.egg
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.eggs/
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
env/
|
|
15
|
+
|
|
16
|
+
# IDE
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
*.swp
|
|
20
|
+
*.swo
|
|
21
|
+
|
|
22
|
+
# OS
|
|
23
|
+
.DS_Store
|
|
24
|
+
Thumbs.db
|
|
25
|
+
|
|
26
|
+
# Tooling caches
|
|
27
|
+
.mypy_cache/
|
|
28
|
+
.ruff_cache/
|
|
29
|
+
.pytest_cache/
|
|
30
|
+
.coverage
|
|
31
|
+
htmlcov/
|
|
32
|
+
coverage.xml
|
|
33
|
+
*.cover
|
|
34
|
+
|
|
35
|
+
# Project
|
|
36
|
+
ref/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.6.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args: [--fix]
|
|
7
|
+
- id: ruff-format
|
|
8
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
9
|
+
rev: v1.11.0
|
|
10
|
+
hooks:
|
|
11
|
+
- id: mypy
|
|
12
|
+
additional_dependencies: []
|
|
13
|
+
args: [--strict]
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to tmpkit will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Nothing yet.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Nothing yet.
|
|
17
|
+
|
|
18
|
+
### Deprecated
|
|
19
|
+
|
|
20
|
+
- Nothing yet.
|
|
21
|
+
|
|
22
|
+
### Removed
|
|
23
|
+
|
|
24
|
+
- Nothing yet.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Nothing yet.
|
|
29
|
+
|
|
30
|
+
### Security
|
|
31
|
+
|
|
32
|
+
- Nothing yet.
|
|
33
|
+
|
|
34
|
+
## [1.0.0] - 2025-01-24
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- Project design documents in `ref/` (context, competitor analysis, features, design, API contract, object spec, migration guide).
|
|
39
|
+
- `temp_file()` sync context manager with auto-cleanup.
|
|
40
|
+
- `temp_dir()` sync context manager with auto-cleanup.
|
|
41
|
+
- `temp_file()` async context manager.
|
|
42
|
+
- `temp_dir()` async context manager.
|
|
43
|
+
- `DEBUG=1` / `TMPKIT_DEBUG=1` environment variable to keep all temps.
|
|
44
|
+
- `keep=True` parameter for per-call keep override.
|
|
45
|
+
- `keep_on_error=True` parameter — keep temp only on exception (killer feature).
|
|
46
|
+
- `.keep()` method — runtime decision to keep temp.
|
|
47
|
+
- `cwd=True` parameter in `temp_dir()` — auto-chdir with restore.
|
|
48
|
+
- `content=` parameter in `temp_file()` — pre-populate file content.
|
|
49
|
+
- `dir=` parameter — specify parent directory.
|
|
50
|
+
- `mode=` parameter in `temp_file()` — text/binary mode control.
|
|
51
|
+
- Close-without-delete — file survives `close()`, deleted on context exit (Windows subprocess friendly).
|
|
52
|
+
- `.path` attribute — `Path` object on temp file objects.
|
|
53
|
+
- `__fspath__` protocol — temp objects work with `os.path`, `shutil`, `subprocess`.
|
|
54
|
+
- `ignore_cleanup_errors=True` by default — best-effort cleanup on Windows.
|
|
55
|
+
- `prefix=` and `suffix=` support.
|
|
56
|
+
- Returns `Path` objects (not raw strings).
|
|
57
|
+
- Named temps by default — Windows-safe (no `O_TEMPORARY` flag).
|
|
58
|
+
- `atomic_write()` context manager — temp file + atomic rename on success.
|
|
59
|
+
- `dest=` parameter in `temp_file()` — promote temp to permanent destination.
|
|
60
|
+
- `@temp_dir()` and `@temp_file()` decorator support.
|
|
61
|
+
- Cleanup hooks.
|
|
62
|
+
- Temp registry — process-local tracking of all temps.
|
|
63
|
+
|
|
64
|
+
### Changed
|
|
65
|
+
|
|
66
|
+
- Nothing yet.
|
|
67
|
+
|
|
68
|
+
### Deprecated
|
|
69
|
+
|
|
70
|
+
- Nothing yet.
|
|
71
|
+
|
|
72
|
+
### Removed
|
|
73
|
+
|
|
74
|
+
- Nothing yet.
|
|
75
|
+
|
|
76
|
+
### Fixed
|
|
77
|
+
|
|
78
|
+
- Registry records are no longer marked `cleaned` when cleanup fails — the
|
|
79
|
+
registry now reflects on-disk reality so `cleanup_all()` can retry.
|
|
80
|
+
- `cleanup_all()` no longer counts already-gone temps as deleted, and
|
|
81
|
+
re-checks record state under the lock to prevent a race condition where
|
|
82
|
+
a concurrently-kept record could be deleted.
|
|
83
|
+
- `atomic_write()` no longer passes `newline`/`encoding` to `os.fdopen` in
|
|
84
|
+
binary mode (previously raised `TypeError`).
|
|
85
|
+
- `.keep()` now raises `RuntimeError` if called after `__exit__` instead
|
|
86
|
+
of silently succeeding.
|
|
87
|
+
- `atomic_write()` now raises `NotADirectoryError` when the destination
|
|
88
|
+
parent exists but is a file, instead of a confusing `OSError` from
|
|
89
|
+
`mkstemp`.
|
|
90
|
+
- `TempFileLike` protocol `read()` signature now matches the
|
|
91
|
+
implementation (`read(size: int = -1)`).
|
|
92
|
+
- `@temp_file()` decorator docstring no longer claims method support.
|
|
93
|
+
- `cleanup_hook` failure no longer prevents standard cleanup — the temp
|
|
94
|
+
file/directory is always cleaned up, and the hook error is re-raised
|
|
95
|
+
after cleanup (body exceptions take precedence).
|
|
96
|
+
- Context manager reuse (`__enter__` called twice) now correctly resets
|
|
97
|
+
internal state instead of raising stale `ValueError` or `RuntimeError`.
|
|
98
|
+
|
|
99
|
+
### Security
|
|
100
|
+
|
|
101
|
+
- `prefix` and `suffix` parameters are now validated to reject path
|
|
102
|
+
separators and absolute paths, preventing path traversal via
|
|
103
|
+
`tempfile.mkstemp`/`mkdtemp`.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
- Demonstrating empathy and kindness toward other people
|
|
21
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
- Giving and gracefully accepting constructive feedback
|
|
23
|
+
- Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
- Focusing on what is best for the overall community, not just us as
|
|
26
|
+
individuals
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
- The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
- Public or private harassment
|
|
34
|
+
- Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
**conduct@mathiaspaulenko.com**.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
<https://www.contributor-covenant.org/faq>. Translations are available at
|
|
128
|
+
<https://www.contributor-covenant.org/translations>.
|