Skip to content

Commit 3f82ab3

Browse files
committed
Initial commit: TSignal - Python Signal/Slot Implementation
A Python implementation of the signal-slot pattern inspired by Qt, featuring: - Easy-to-use signal-slot mechanism with decorators - Support for both synchronous and asynchronous slots - Thread-safe signal emissions - Automatic connection type detection - Comprehensive test suite - Full documentation Project structure: - src/tsignal: Core implementation - tests: Unit and integration tests - examples: Usage examples - docs: Detailed documentation Documentation includes: - API reference - Usage guide - Example patterns - Testing guide - Logging guidelines - Contributing guide
0 parents  commit 3f82ab3

26 files changed

+2095
-0
lines changed

.gitattribuites

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Python files
5+
*.py text diff=python eol=lf
6+
*.pyi text diff=python eol=lf
7+
8+
# Documentation
9+
*.md text eol=lf
10+
*.rst text eol=lf
11+
docs/* text eol=lf
12+
13+
# Scripts
14+
*.sh text eol=lf
15+
*.bat text eol=crlf
16+
*.cmd text eol=crlf
17+
*.ps1 text eol=crlf
18+
19+
# Configuration
20+
*.yml text eol=lf
21+
*.yaml text eol=lf
22+
*.json text eol=lf
23+
*.toml text eol=lf
24+
.gitattributes text eol=lf
25+
.gitignore text eol=lf
26+
requirements.txt text eol=lf

.github/workflows/tests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install pytest pytest-cov pytest-asyncio
28+
pip install -e ".[dev]"
29+
30+
- name: Run tests
31+
run: |
32+
pytest --cov=tsignal

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
7+
# Distribution / packaging
8+
dist/
9+
build/
10+
*.egg-info/
11+
*.egg
12+
13+
# Virtual environments
14+
venv/
15+
env/
16+
.env/
17+
.venv/
18+
ENV/
19+
20+
# Testing
21+
.pytest_cache/
22+
.coverage
23+
htmlcov/
24+
.tox/
25+
26+
# IDE settings
27+
.idea/
28+
.vscode/
29+
*.swp
30+
*.swo
31+
*~
32+
33+
# Logs
34+
*.log
35+
36+
# Environment variables
37+
.env
38+
.env.local
39+
40+
# macOS
41+
.DS_Store
42+
43+
# Jupyter Notebook
44+
.ipynb_checkpoints
45+
46+
# mypy
47+
.mypy_cache/
48+
49+
# Documentation builds
50+
docs/_build/

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [0.1.0] - 2024-01-26
8+
9+
### Added
10+
- Initial release
11+
- Basic signal-slot mechanism with decorators
12+
- Support for both synchronous and asynchronous slots
13+
- Thread-safe signal emissions
14+
- Automatic connection type detection
15+
- Comprehensive test suite
16+
- Full documentation

CONTRIBUTING.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Contributing to TSignal
2+
3+
Thank you for your interest in contributing to TSignal! This document provides guidelines and instructions for contributing to the project.
4+
5+
## Development Setup
6+
7+
1. Fork and clone the repository:
8+
```bash
9+
git clone https://github.com/TSignalDev/tsignal-python.git
10+
cd tsignal-python
11+
```
12+
13+
2. Create a virtual environment and install development dependencies:
14+
```bash
15+
python -m venv venv
16+
source venv/bin/activate # On Windows: venv\Scripts\activate
17+
pip install -e ".[dev]"
18+
```
19+
20+
## Code Style
21+
22+
We follow these coding conventions:
23+
- PEP 8 style guide
24+
- Maximum line length of 88 characters (Black default)
25+
- Type hints for function arguments and return values
26+
- Docstrings for all public modules, functions, classes, and methods
27+
28+
## Testing
29+
30+
Run the test suite before submitting changes:
31+
```bash
32+
# Run all tests
33+
pytest
34+
35+
# Run with coverage
36+
pytest --cov=tsignal
37+
38+
# Run specific test file
39+
pytest tests/unit/test_signal.py
40+
41+
# Enable debug logging during tests
42+
TSIGNAL_DEBUG=1 pytest
43+
```
44+
45+
## Pull Request Process
46+
47+
1. Create a new branch for your feature or bugfix:
48+
```bash
49+
git checkout -b feature-name
50+
```
51+
52+
2. Make your changes and commit them:
53+
```bash
54+
git add .
55+
git commit -m "Description of changes"
56+
```
57+
58+
3. Ensure your changes include:
59+
- Tests for any new functionality
60+
- Documentation updates if needed
61+
- No unnecessary debug prints or commented code
62+
- Type hints for new functions/methods
63+
64+
4. Push your changes and create a pull request:
65+
```bash
66+
git push origin feature-name
67+
```
68+
69+
5. In your pull request description:
70+
- Describe what the changes do
71+
- Reference any related issues
72+
- Note any breaking changes
73+
- Include examples if applicable
74+
75+
## Development Guidelines
76+
77+
### Adding New Features
78+
79+
1. Start with tests
80+
2. Implement the feature
81+
3. Update documentation
82+
4. Add examples if applicable
83+
84+
### Debug Logging
85+
86+
Use appropriate log levels:
87+
```python
88+
import logging
89+
90+
logger = logging.getLogger(__name__)
91+
92+
# Debug information
93+
logger.debug("Detailed connection info")
94+
95+
# Important state changes
96+
logger.info("Signal connected successfully")
97+
98+
# Warning conditions
99+
logger.warning("Multiple connections detected")
100+
101+
# Errors
102+
logger.error("Failed to emit signal", exc_info=True)
103+
```
104+
105+
## Code of Conduct
106+
107+
### Our Standards
108+
109+
- Be respectful and inclusive
110+
- Focus on constructive criticism
111+
- Accept feedback gracefully
112+
- Put the project's best interests first
113+
114+
### Enforcement
115+
116+
Violations of the code of conduct may result in:
117+
1. Warning
118+
2. Temporary ban
119+
3. Permanent ban
120+
121+
Report issues to project maintainers via email.
122+
123+
## License
124+
125+
By contributing, you agree that your contributions will be licensed under the same license as the project (MIT License).

LICENCSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 San Kim
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 commit comments

Comments
 (0)