winipedia-utils 0.6.6__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.
Potentially problematic release.
This version of winipedia-utils might be problematic. Click here for more details.
- winipedia_utils-0.6.6/LICENSE +21 -0
- winipedia_utils-0.6.6/PKG-INFO +390 -0
- winipedia_utils-0.6.6/README.md +362 -0
- winipedia_utils-0.6.6/pyproject.toml +69 -0
- winipedia_utils-0.6.6/winipedia_utils/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/artifacts/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/artifacts/build.py +78 -0
- winipedia_utils-0.6.6/winipedia_utils/concurrent/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/concurrent/concurrent.py +250 -0
- winipedia_utils-0.6.6/winipedia_utils/concurrent/multiprocessing.py +129 -0
- winipedia_utils-0.6.6/winipedia_utils/concurrent/multithreading.py +93 -0
- winipedia_utils-0.6.6/winipedia_utils/data/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/data/dataframe/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/data/dataframe/cleaning.py +615 -0
- winipedia_utils-0.6.6/winipedia_utils/data/structures/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/data/structures/dicts.py +16 -0
- winipedia_utils-0.6.6/winipedia_utils/git/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/github.py +31 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/repo/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/repo/protect.py +103 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/repo/repo.py +205 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/workflows/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/workflows/base/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/workflows/base/base.py +889 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/workflows/health_check.py +69 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/workflows/publish.py +51 -0
- winipedia_utils-0.6.6/winipedia_utils/git/github/workflows/release.py +90 -0
- winipedia_utils-0.6.6/winipedia_utils/git/gitignore/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/git/gitignore/config.py +77 -0
- winipedia_utils-0.6.6/winipedia_utils/git/gitignore/gitignore.py +78 -0
- winipedia_utils-0.6.6/winipedia_utils/git/pre_commit/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/git/pre_commit/config.py +60 -0
- winipedia_utils-0.6.6/winipedia_utils/git/pre_commit/hooks.py +127 -0
- winipedia_utils-0.6.6/winipedia_utils/git/pre_commit/run_hooks.py +56 -0
- winipedia_utils-0.6.6/winipedia_utils/iterating/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/iterating/iterate.py +91 -0
- winipedia_utils-0.6.6/winipedia_utils/logging/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/logging/ansi.py +6 -0
- winipedia_utils-0.6.6/winipedia_utils/logging/config.py +64 -0
- winipedia_utils-0.6.6/winipedia_utils/logging/logger.py +26 -0
- winipedia_utils-0.6.6/winipedia_utils/modules/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/modules/class_.py +176 -0
- winipedia_utils-0.6.6/winipedia_utils/modules/function.py +124 -0
- winipedia_utils-0.6.6/winipedia_utils/modules/inspection.py +56 -0
- winipedia_utils-0.6.6/winipedia_utils/modules/module.py +373 -0
- winipedia_utils-0.6.6/winipedia_utils/modules/package.py +496 -0
- winipedia_utils-0.6.6/winipedia_utils/oop/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/oop/mixins/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/oop/mixins/meta.py +333 -0
- winipedia_utils-0.6.6/winipedia_utils/oop/mixins/mixin.py +37 -0
- winipedia_utils-0.6.6/winipedia_utils/os/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/os/os.py +63 -0
- winipedia_utils-0.6.6/winipedia_utils/projects/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/projects/poetry/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/projects/poetry/config.py +260 -0
- winipedia_utils-0.6.6/winipedia_utils/projects/poetry/poetry.py +248 -0
- winipedia_utils-0.6.6/winipedia_utils/projects/project.py +17 -0
- winipedia_utils-0.6.6/winipedia_utils/py.typed +1 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/delete_garbage_can.svg +2 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/download_arrow.svg +3 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/exit_fullscreen_icon.svg +7 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/fullscreen_icon.svg +4 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/menu_icon.svg +4 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/pause_icon.svg +4 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/play_icon.svg +17 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/plus_icon.svg +24 -0
- winipedia_utils-0.6.6/winipedia_utils/resources/svgs/svg.py +15 -0
- winipedia_utils-0.6.6/winipedia_utils/security/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/security/cryptography.py +29 -0
- winipedia_utils-0.6.6/winipedia_utils/security/keyring.py +70 -0
- winipedia_utils-0.6.6/winipedia_utils/setup.py +41 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/assertions.py +48 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/config.py +127 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/convention.py +177 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/create_tests.py +283 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/fixtures.py +28 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/skip.py +19 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/fixture.py +42 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/scopes/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/scopes/class_.py +33 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/scopes/function.py +7 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/scopes/module.py +36 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/scopes/package.py +7 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/fixtures/scopes/session.py +181 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/utils/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/base/utils/utils.py +81 -0
- winipedia_utils-0.6.6/winipedia_utils/testing/tests/conftest.py +32 -0
- winipedia_utils-0.6.6/winipedia_utils/text/__init__.py +1 -0
- winipedia_utils-0.6.6/winipedia_utils/text/config.py +250 -0
- winipedia_utils-0.6.6/winipedia_utils/text/string.py +156 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Winipedia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: winipedia-utils
|
|
3
|
+
Version: 0.6.6
|
|
4
|
+
Summary: A package with many utility functions
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: Winipedia
|
|
8
|
+
Author-email: win.steveker@gmx.de
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Dist: cryptography
|
|
15
|
+
Requires-Dist: defusedxml
|
|
16
|
+
Requires-Dist: dotenv
|
|
17
|
+
Requires-Dist: keyring
|
|
18
|
+
Requires-Dist: networkx
|
|
19
|
+
Requires-Dist: pathspec
|
|
20
|
+
Requires-Dist: polars
|
|
21
|
+
Requires-Dist: pygithub
|
|
22
|
+
Requires-Dist: pyyaml
|
|
23
|
+
Requires-Dist: setuptools
|
|
24
|
+
Requires-Dist: tomlkit
|
|
25
|
+
Requires-Dist: tqdm
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# Winipedia Utils
|
|
29
|
+
|
|
30
|
+
A comprehensive Python utility package that enforces best practices, automates project setup, and provides a complete testing framework for modern Python projects.
|
|
31
|
+
|
|
32
|
+
> **Note:** Code examples in this README are provided for reference. Please check the source code and docstrings for complete and accurate implementations.
|
|
33
|
+
|
|
34
|
+
[](https://www.python.org/downloads/)
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
[](https://github.com/astral-sh/ruff)
|
|
37
|
+
|
|
38
|
+
## Table of Contents
|
|
39
|
+
|
|
40
|
+
- [Overview](#overview)
|
|
41
|
+
- [Key Features](#key-features)
|
|
42
|
+
- [Quick Start](#quick-start)
|
|
43
|
+
- [Setup Process](#setup-process)
|
|
44
|
+
- [Utilities](#utilities)
|
|
45
|
+
- [Configuration Files](#configuration-files)
|
|
46
|
+
- [Important Notes](#important-notes)
|
|
47
|
+
- [Requirements](#requirements)
|
|
48
|
+
|
|
49
|
+
## Overview
|
|
50
|
+
|
|
51
|
+
**Winipedia Utils** is a utility library that serves two primary purposes:
|
|
52
|
+
|
|
53
|
+
1. **Utility Package** - Provides reusable functions across several domains (concurrency, data handling, security, testing, etc.)
|
|
54
|
+
2. **Project Framework** - Automates project setup, testing infrastructure, code quality checks, and best practices enforcement
|
|
55
|
+
|
|
56
|
+
## Key Features
|
|
57
|
+
|
|
58
|
+
- **Automatic Test Generation** - Creates mirror test structure matching your source code
|
|
59
|
+
- **Security First** - Built-in encryption, keyring integration, and security scanning
|
|
60
|
+
- **Concurrent Processing** - Unified interface for multiprocessing and multithreading
|
|
61
|
+
- **Data Handling** - Polars-based dataframe utilities with cleaning pipelines
|
|
62
|
+
- **Strict Type Checking** - mypy in strict mode with full type annotations
|
|
63
|
+
- **Code Quality** - Automated linting, formatting, and security checks
|
|
64
|
+
- **Comprehensive Logging** - Automatic method instrumentation and performance tracking
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### How to setup a new project
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# 1: Create a new repository on GitHub
|
|
72
|
+
# The default branch must be called main
|
|
73
|
+
# add a PAT or Fine-Grained Access Token to your repo secrets called REPO_TOKEN that has write access to the repository (Adminstration and Contents)(needed for branch protection in health_check.yaml - see winipedia_utils.git.github.repo.protect and for commiting as an action in release.yaml)
|
|
74
|
+
|
|
75
|
+
# 2: Clone the repository
|
|
76
|
+
git clone https://github.com/owner/repo.git
|
|
77
|
+
|
|
78
|
+
# 3: Create a new poetry project
|
|
79
|
+
poetry init # or poetry new
|
|
80
|
+
# 4: Poetry will ask you some stuff when you run poetry init.
|
|
81
|
+
# First author name must be equal to the GitHub repository owner (username).
|
|
82
|
+
# The repository name must be equal to the package/project name.
|
|
83
|
+
# (- instead of _ is fine, but only as the project name in pyproject.toml, folder names should all be _)
|
|
84
|
+
|
|
85
|
+
# 5: Add winipedia-utils to your project
|
|
86
|
+
poetry add winipedia-utils
|
|
87
|
+
|
|
88
|
+
# 6: Run the automated setup
|
|
89
|
+
poetry run python -m winipedia_utils.setup
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The setup script will automatically configure your project with all necessary files and standards.
|
|
93
|
+
|
|
94
|
+
## Setup Process
|
|
95
|
+
|
|
96
|
+
The `winipedia_utils.setup` command automates the entire project initialization in three main steps:
|
|
97
|
+
|
|
98
|
+
1. **Initialize Configuration Files** - Creates all necessary config files with standard configurations
|
|
99
|
+
2. **Create Project Root** - Sets up the project root directory with __init__.py files
|
|
100
|
+
3. **Run Pre-commit Hooks** - Executes all pre-commit hooks to validate the setup
|
|
101
|
+
|
|
102
|
+
### Generated Configuration Files
|
|
103
|
+
|
|
104
|
+
The setup creates the following configuration files:
|
|
105
|
+
- `.pre-commit-config.yaml` - Pre-commit hook configuration
|
|
106
|
+
- `.gitignore` - Git ignore rules (assumes you added one on GitHub before.)
|
|
107
|
+
- `pyproject.toml` - Project configuration with Poetry settings
|
|
108
|
+
- `.github/workflows/health_check.yaml` - Health check workflow (Runs on every push and pull request using a matrix strategy to test across multiple operating systems and Python versions)
|
|
109
|
+
- `.github/workflows/release.yaml` - Release workflow (Creates a release on GitHub when the same actions as in health check pass and commits are pushed to main)
|
|
110
|
+
- `.github/workflows/publish.yaml` - Publishing workflow (Publishes to PyPI when a release is created by the release workflow, if you use this workflow, you need to add a PYPI_TOKEN (named PYPI_TOKEN) to your GitHub secrets that has write access to the package on PyPI.)
|
|
111
|
+
- `py.typed` - PEP 561 marker for type hints
|
|
112
|
+
- `experiment.py` - For experimentation (ignored by git)
|
|
113
|
+
- `test_zero.py` - Test file with one empyt test (so that initial tests pass)
|
|
114
|
+
- `conftest.py` - Pytest configuration file
|
|
115
|
+
- `.python-version` - Python version file for pyenv (if you use pyenv, puts in the lowest supported python version in pyproject.toml opposed to the latest possible python version in workflows)
|
|
116
|
+
|
|
117
|
+
### GitHub Workflows and Matrix Strategy
|
|
118
|
+
|
|
119
|
+
The project uses GitHub Actions workflows with a **matrix strategy** to ensure cross-platform compatibility:
|
|
120
|
+
|
|
121
|
+
#### Matrix Configuration
|
|
122
|
+
|
|
123
|
+
The health check and release workflows test your code across:
|
|
124
|
+
- **Operating Systems**: Ubuntu (latest), Windows (latest), macOS (latest)
|
|
125
|
+
- **Python Versions**: All versions specified in your `pyproject.toml` (e.g., 3.12, 3.13, 3.14)
|
|
126
|
+
|
|
127
|
+
This matrix strategy ensures your code works reliably across different environments before merging or releasing.
|
|
128
|
+
|
|
129
|
+
#### Workflow Structure
|
|
130
|
+
|
|
131
|
+
The health check workflow consists of two jobs:
|
|
132
|
+
|
|
133
|
+
1. **Matrix Job** (`health_check_matrix`) - Runs all checks in parallel across the matrix of OS and Python versions:
|
|
134
|
+
- Checkout repository
|
|
135
|
+
- Setup Git, Python, and Poetry
|
|
136
|
+
- Add Poetry to PATH (Windows-specific step)
|
|
137
|
+
- Install dependencies
|
|
138
|
+
- Setup CI keyring
|
|
139
|
+
- Protect repository (applies branch protection rules and repository settings)
|
|
140
|
+
- Run pre-commit hooks (linting, formatting, type checking, security, tests)
|
|
141
|
+
|
|
142
|
+
2. **Aggregation Job** (`health_check`) - Aggregates matrix results into a single status check:
|
|
143
|
+
- Required for branch protection compatibility
|
|
144
|
+
- Only runs after all matrix jobs complete successfully
|
|
145
|
+
- Provides a single status check that can be marked as required in branch protection rules
|
|
146
|
+
|
|
147
|
+
The release workflow extends the health check workflow and adds a release job that runs after all health checks pass.
|
|
148
|
+
A build job is added before the release job if a script src/artifacts/build.py exists. This script is created by the setup command and can be modified to create build artifacts for your project. This script then just needs to create artifacts in a folder called artifacts and those will be uploaded as artifacts to the release.
|
|
149
|
+
|
|
150
|
+
### Pre-commit Hook Workflow
|
|
151
|
+
|
|
152
|
+
When you commit code using `git commit`, the following checks run automatically:
|
|
153
|
+
|
|
154
|
+
Info: If git commit fails bc of ModuleNotFoundError or smth similar, you need to run `poetry run git commit` instead.
|
|
155
|
+
winipedia_utils hook is a python script that depends on winipedia_utils being installed. Poetry is needed to install winipedia_utils.
|
|
156
|
+
Usually VSCode or other IDEs activates the venv automatically when opening the terminal but if not you need to activate it manually or run `poetry run git commit` instead. It fails fast, so if one hook in winipedia_utils hook fails, the others don't run bc sys.exit(1) is called.
|
|
157
|
+
|
|
158
|
+
Hooks run in the following order:
|
|
159
|
+
|
|
160
|
+
- Update package manager (poetry self update)
|
|
161
|
+
- Install packages (poetry install --with dev)
|
|
162
|
+
- Update packages (poetry update --with dev (winipedia_utils forces all dependencies with * to be updated to latest compatible version))
|
|
163
|
+
- Lock dependencies (poetry lock)
|
|
164
|
+
- Check package manager configs (poetry check --strict)
|
|
165
|
+
- Create tests (python -m winipedia_utils.testing.create_tests)
|
|
166
|
+
- Lint code (ruff check --fix)
|
|
167
|
+
- Format code (ruff format)
|
|
168
|
+
- Check static types (mypy)
|
|
169
|
+
- Check security (bandit -c pyproject.toml -r .)
|
|
170
|
+
- Run tests (pytest (uses pyproject.toml as config))
|
|
171
|
+
|
|
172
|
+
### Auto-generated Test Structure
|
|
173
|
+
|
|
174
|
+
The test generation creates a **mirror structure** of your source code:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
my_project/
|
|
178
|
+
├── my_project/
|
|
179
|
+
│ ├── module_a.py
|
|
180
|
+
│ └── package_b/
|
|
181
|
+
│ └── module_c.py
|
|
182
|
+
└── tests/
|
|
183
|
+
├── test_module_a.py
|
|
184
|
+
└── test_package_b/
|
|
185
|
+
└── test_module_c.py
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
For each function, class, and method, skeleton tests are created with `NotImplementedError` placeholders for you to implement.
|
|
189
|
+
|
|
190
|
+
If you have autosuse fixtures just write and add them to the `tests/base/fixtures` directory. They will be automatically discovered, plugged into conftest and used in all tests according to defined scope.
|
|
191
|
+
The filenames in the fixtures folder are just for organisation purposes for your convenience. You still have to
|
|
192
|
+
apply the pytest.fixture decorator to the fixture function and define the scope. So a session scoped function defined on function.py will still run as a session scoped fixture.
|
|
193
|
+
|
|
194
|
+
## Configuration Files
|
|
195
|
+
|
|
196
|
+
Configuration files are managed automatically by the setup system:
|
|
197
|
+
|
|
198
|
+
- **Deleted files** - If you delete a config file, it will be recreated with standard configurations
|
|
199
|
+
- **Empty files** - If you want to disable a config file, make it empty. This signals that the file is unwanted and won't be modified
|
|
200
|
+
- **Custom additions** - You can add custom configurations as long as the standard configurations remain intact
|
|
201
|
+
- **Modified standards** - If you modify the standard configurations, they will be restored on the next setup run
|
|
202
|
+
- **Subclasses** - You can create custom config files by subclassing the standard ones. They will be automatically created and managed when you commit or run pytest. winipedia_utils automatically discovers and calls them. This way you can adjust or add some settings. It is however important the parent class stays a subset of the child class according to the description in the function `nested_structure_is_subset` in `winipedia_utils.iterating.iterate`.
|
|
203
|
+
|
|
204
|
+
## Branch Protection
|
|
205
|
+
|
|
206
|
+
As soon as you push to `main` on GitHub (provided the `REPO_TOKEN` secret is set up correctly), the `health_check.yaml` workflow will run and execute `winipedia_utils.git.github.repo.protect`, which uses PyGithub to protect the repository.
|
|
207
|
+
|
|
208
|
+
### Repository Settings
|
|
209
|
+
|
|
210
|
+
The following repository settings are configured:
|
|
211
|
+
|
|
212
|
+
- **name** - Repository name from `pyproject.toml` or folder name (should match repo name)
|
|
213
|
+
- **description** - Repository description from `pyproject.toml`
|
|
214
|
+
- **default_branch** - `main`
|
|
215
|
+
- **delete_branch_on_merge** - `true`
|
|
216
|
+
- **allow_update_branch** - `true`
|
|
217
|
+
- **allow_merge_commit** - `false`
|
|
218
|
+
- **allow_rebase_merge** - `true`
|
|
219
|
+
- **allow_squash_merge** - `true`
|
|
220
|
+
|
|
221
|
+
### Branch Protection Rules
|
|
222
|
+
|
|
223
|
+
A ruleset named `main protection` is created for the `main` branch with the following rules:
|
|
224
|
+
|
|
225
|
+
- **Deletion** - Prevents branch deletion
|
|
226
|
+
- **Non-fast-forward** - Prevents non-fast-forward pushes (forces linear history by rejecting force pushes)
|
|
227
|
+
- **Creation** - Prevents branch creation directly on the protected branch
|
|
228
|
+
- **Update** - Prevents direct updates to protected branch (all changes must go through pull requests)
|
|
229
|
+
- **Required Linear History** - Enforces linear commit history (no merge commits allowed)
|
|
230
|
+
- **Required Signatures** - Requires all commits to be signed with GPG or SSH keys
|
|
231
|
+
- **Pull Request Requirements:**
|
|
232
|
+
- Requires 1 approving review (at least one person must approve before merge)
|
|
233
|
+
- Dismisses stale reviews on push (if you push a new commit, all reviews are dismissed and must be re-approved)
|
|
234
|
+
- Requires code owner review (designated code owners must approve changes to their files)
|
|
235
|
+
- Requires last push approval (the most recent push must be approved, not an earlier one)
|
|
236
|
+
- Requires review thread resolution (all comments in reviews must be resolved before merge)
|
|
237
|
+
- Allowed merge methods: `squash` and `rebase` (no merge commits, keeps history clean)
|
|
238
|
+
- **Required Status Checks:**
|
|
239
|
+
- Strict mode enabled (all status checks must pass on the latest commit, not older ones)
|
|
240
|
+
- Health check workflow must pass (the aggregated `health_check` job ensures all matrix combinations passed successfully)
|
|
241
|
+
- **Bypass Actors** - Repository admins can bypass all rules (for emergency situations)
|
|
242
|
+
|
|
243
|
+
## Utilities
|
|
244
|
+
|
|
245
|
+
Winipedia Utils provides comprehensive utility modules for common development tasks:
|
|
246
|
+
|
|
247
|
+
### Concurrent Processing
|
|
248
|
+
|
|
249
|
+
Unified interface for multiprocessing and multithreading:
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
from winipedia_utils.concurrent.multiprocessing import multiprocess_loop
|
|
253
|
+
from winipedia_utils.concurrent.multithreading import multithread_loop
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Data Cleaning & Handling
|
|
257
|
+
|
|
258
|
+
Build data cleaning pipelines using Polars:
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
from winipedia_utils.data.dataframe.cleaning import CleaningDF
|
|
262
|
+
import polars as pl
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Logging Utilities
|
|
266
|
+
|
|
267
|
+
Simple, standardized logging setup with automatic method instrumentation:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
from winipedia_utils.logging.logger import get_logger
|
|
271
|
+
|
|
272
|
+
logger = get_logger(__name__)
|
|
273
|
+
logger.info("Application started")
|
|
274
|
+
logger.warning("This is a warning")
|
|
275
|
+
logger.error("An error occurred")
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**Features:**
|
|
279
|
+
- Pre-configured logging levels
|
|
280
|
+
- ANSI color support for terminal output
|
|
281
|
+
- Automatic method logging via metaclasses
|
|
282
|
+
|
|
283
|
+
### Object-Oriented Programming Utilities
|
|
284
|
+
|
|
285
|
+
Advanced metaclasses and mixins for class composition and behavior extension:
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
from winipedia_utils.oop.mixins.mixin import ABCLoggingMixin, StrictABCLoggingMixin
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Security Utilities
|
|
292
|
+
|
|
293
|
+
Encryption and secure credential storage using keyring:
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from winipedia_utils.security.keyring import (
|
|
297
|
+
get_or_create_fernet,
|
|
298
|
+
get_or_create_aes_gcm
|
|
299
|
+
)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Testing Utilities
|
|
303
|
+
|
|
304
|
+
Comprehensive testing framework with automatic test generation:
|
|
305
|
+
|
|
306
|
+
```python
|
|
307
|
+
from winipedia_utils.testing.assertions import assert_with_msg
|
|
308
|
+
from winipedia_utils.testing.convention import (
|
|
309
|
+
make_test_obj_name,
|
|
310
|
+
get_test_obj_from_obj,
|
|
311
|
+
make_test_obj_importpath_from_obj
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
# Custom assertions
|
|
315
|
+
assert_with_msg(result == expected, "Result does not match expected value")
|
|
316
|
+
|
|
317
|
+
# Test naming conventions
|
|
318
|
+
test_name = make_test_obj_name(my_function) # "test_my_function"
|
|
319
|
+
|
|
320
|
+
# Get corresponding test object
|
|
321
|
+
test_obj = get_test_obj_from_obj(my_function)
|
|
322
|
+
|
|
323
|
+
# Get test import path
|
|
324
|
+
test_path = make_test_obj_importpath_from_obj(my_function)
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**Features:**
|
|
328
|
+
- Automatic test file generation
|
|
329
|
+
- Mirror test structure matching source code
|
|
330
|
+
- Test naming conventions
|
|
331
|
+
- Fixture management with scopes (function, class, module, package, session)
|
|
332
|
+
|
|
333
|
+
### Module Introspection Utilities
|
|
334
|
+
|
|
335
|
+
Tools for working with Python modules, packages, classes, and functions:
|
|
336
|
+
|
|
337
|
+
```python
|
|
338
|
+
from winipedia_utils.modules.package import find_packages, walk_package
|
|
339
|
+
from winipedia_utils.modules.module import create_module, import_obj_from_importpath
|
|
340
|
+
from winipedia_utils.modules.class_ import get_all_cls_from_module, get_all_methods_from_cls
|
|
341
|
+
from winipedia_utils.modules.function import get_all_functions_from_module
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Text and String Utilities
|
|
345
|
+
|
|
346
|
+
String manipulation and configuration file handling:
|
|
347
|
+
|
|
348
|
+
```python
|
|
349
|
+
from winipedia_utils.text.string import value_to_truncated_string
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### OS and System Utilities
|
|
353
|
+
|
|
354
|
+
Operating system and subprocess utilities:
|
|
355
|
+
|
|
356
|
+
```python
|
|
357
|
+
from winipedia_utils.os.os import run_subprocess
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Iteration Utilities
|
|
361
|
+
|
|
362
|
+
Utilities for working with iterables and nested structures:
|
|
363
|
+
|
|
364
|
+
```python
|
|
365
|
+
from winipedia_utils.iterating.iterate import get_len_with_default, nested_structure_is_subset
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Philosophy
|
|
369
|
+
|
|
370
|
+
The core philosophy of Winipedia Utils is to:
|
|
371
|
+
|
|
372
|
+
> **Enforce good habits, ensure clean code, and save time when starting new projects**
|
|
373
|
+
|
|
374
|
+
By automating setup, testing, linting, formatting, and type checking, you can focus on writing business logic instead of configuring tools.
|
|
375
|
+
|
|
376
|
+
## Requirements
|
|
377
|
+
|
|
378
|
+
- **Python:** 3.12 or higher
|
|
379
|
+
- **Poetry:** For dependency management
|
|
380
|
+
- **Git:** For version control and pre-commit hooks
|
|
381
|
+
|
|
382
|
+
## License
|
|
383
|
+
|
|
384
|
+
MIT License - See [LICENSE](LICENSE) file for details
|
|
385
|
+
|
|
386
|
+
## Contributing
|
|
387
|
+
|
|
388
|
+
Contributions are welcome! Please ensure all code follows the project's quality standards.
|
|
389
|
+
|
|
390
|
+
|