Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0ef0d48
update python package config
TaegyunHa Nov 22, 2025
5d8b389
add d3sdk
TaegyunHa Nov 22, 2025
a0b838a
Update README
TaegyunHa Nov 23, 2025
a310700
fix fstring conversion
TaegyunHa Nov 24, 2025
53683ba
add register_module arg
DevTGHa Nov 27, 2025
d468306
add logger
DevTGHa Nov 29, 2025
e48bb90
add D3_PLUGIN_DEFAULT_PORT
DevTGHa Nov 29, 2025
ae97de5
rename test directory to tests
DevTGHa Nov 29, 2025
3529688
Update readme
DevTGHa Nov 29, 2025
d37cc92
fix mypy
DevTGHa Nov 29, 2025
6490096
update project name for pypi
DevTGHa Nov 29, 2025
0c17b62
ruff format
DevTGHa Nov 29, 2025
fae4093
add twine for pypi
DevTGHa Nov 29, 2025
a4d62ec
update readme for published pypi package
DevTGHa Nov 29, 2025
f8c217f
Rephrase SDK to API
DevTGHa Dec 1, 2025
28436c7
change naming from plugin to execute
DevTGHa Dec 1, 2025
95dd216
reflect feedbacks
DevTGHa Dec 1, 2025
17e64e6
validate arguments
DevTGHa Dec 2, 2025
3959a4e
add github badge
DevTGHa Dec 2, 2025
8fa83d9
Add changelog and contributing
DevTGHa Dec 2, 2025
3ca2601
Update LICENSE
DevTGHa Dec 2, 2025
d99bb28
Update description of pyproject
DevTGHa Dec 2, 2025
8f70087
fix test
DevTGHa Dec 2, 2025
cd8f880
fix type information being removed
DevTGHa Dec 2, 2025
97419e4
fix args and kargs arguments
DevTGHa Dec 2, 2025
117ba40
add override_module_name
DevTGHa Dec 2, 2025
51289b2
raise RuntimeError if not in session
DevTGHa Dec 2, 2025
985d887
Update CHANGELOG.md
DevTGHa Dec 3, 2025
6674d83
remove all d3 implication in docstring
DevTGHa Dec 3, 2025
53342f1
add support for args and kargs
DevTGHa Dec 3, 2025
ac3b315
fix module_name in build_payload
DevTGHa Dec 3, 2025
6725873
Update pyproject.toml
DevTGHa Dec 3, 2025
12da4bb
hide expensive logging under isEnableFor
DevTGHa Dec 3, 2025
f458cf3
fix default argument for constructor
DevTGHa Dec 3, 2025
d9a39ee
always intialise D3PluginClient
DevTGHa Dec 5, 2025
720a7bb
british english
DevTGHa Dec 5, 2025
9a9c3a2
fix for constructingn D3PluginClient
DevTGHa Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,6 @@ cython_debug/

# PyPI configuration file
.pypirc

# MacOS
.DS_Store
12 changes: 4 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false
}
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.2.0] - 2025-12-02

### Added
- **Client API**: Metaclass-based remote method execution with `D3PluginClient`
- Support for both sync and async methods
- Automatic Python 2.7 code conversion for Designer compatibility
- Session management with context managers
- **Functional API**: Decorator-based remote execution
- `@d3pythonscript` decorator for one-off script execution
- `@d3function(module_name)` decorator for reusable module-based functions
- Function chaining support within modules
- **Session Management**: `D3Session` and `D3AsyncSession` classes
- `rpc()` method for simple return value retrieval
- `execute()` method for full response with logs and status
- Automatic module registration via context managers
- **Type Safety**: Full Pydantic models for all API interactions
- `PluginPayload`, `PluginResponse`, `RegisterPayload`
- Generic type support for type-safe return values
- **Logging**: Configurable logging with `enable_debug_logging()`
- NullHandler by default (library best practice)
- Granular module-level control
- **AST Utilities**: Python 3 to Python 2.7 code transformation
- F-string to `.format()` conversion
- Type annotation removal
- Async/await removal
- Automatic package import detection
- Comprehensive test suite with 99 tests covering all major functionality
- CI/CD with GitHub Actions (ruff, mypy, pytest)
- PEP 561 type hints marker (`py.typed`)
291 changes: 291 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
# Contributing to designer-plugin

Thank you for your interest in contributing to designer-plugin! This document provides guidelines and instructions for contributing.

## Development Setup

### Prerequisites

- Python 3.11 or higher
- [uv](https://github.com/astral-sh/uv) package manager

### Getting Started

1. **Clone the repository:**
```bash
git clone https://github.com/disguise-one/python-plugin.git
cd python-plugin
```

2. **Install dependencies:**
```bash
uv sync --dev
```

3. **Install pre-commit hooks:**
```bash
uv run pre-commit install
```

## Development Workflow

### Running Tests

Run the full test suite:
```bash
uv run pytest
```

Run tests with verbose output:
```bash
uv run pytest -v
```

Run specific test file:
```bash
uv run pytest tests/test_core.py
```

### Code Quality Checks

**Linting:**
```bash
uv run ruff check
```

**Auto-fix linting issues:**
```bash
uv run ruff check --fix
```

**Formatting:**
```bash
uv run ruff format
```

**Type checking:**
```bash
uv run mypy
```

**Run all checks:**
```bash
uv run ruff check && uv run ruff format --check && uv run mypy && uv run pytest
```

### Pre-commit Hooks

Pre-commit hooks are configured to automatically run:
- `ruff check --fix` - Linting with auto-fix
- `ruff format` - Code formatting

These run automatically on `git commit`. To run manually:
```bash
uv run pre-commit run --all-files
```

## Code Style

### General Guidelines

- Follow PEP 8 style guidelines
- Use type hints for all function signatures
- Write docstrings for all public APIs
- Prefer explicit over implicit

### Type Hints

All code must include type hints:
```python
def my_function(name: str, count: int = 0) -> dict[str, int]:
"""Do something useful.

Args:
name: The name parameter.
count: The count parameter.

Returns:
A dictionary mapping name to count.
"""
return {name: count}
```

### Docstrings

Use Google-style docstrings:
```python
def example_function(param1: str, param2: int) -> bool:
"""Brief description of the function.

More detailed explanation if needed. Can span
multiple lines.

Args:
param1: Description of param1.
param2: Description of param2.

Returns:
Description of return value.

Raises:
ValueError: When param2 is negative.
"""
if param2 < 0:
raise ValueError("param2 must be non-negative")
return True
```

### Code Organization

- Group related functionality together
- Use clear, descriptive names
- Avoid circular imports

## Testing Guidelines

### Test Structure

- Place tests in the `tests/` directory
- Name test files `test_*.py`
- Name test classes `Test*`
- Name test functions `test_*`

### Writing Tests

```python
class TestMyFeature:
"""Test suite for my feature."""

def test_basic_functionality(self) -> None:
"""Test basic functionality works correctly."""
result = my_function("test", 42)
assert result == {"test": 42}

def test_error_handling(self) -> None:
"""Test error handling for invalid input."""
with pytest.raises(ValueError):
my_function("test", -1)
```

### Test Coverage

- Aim for high test coverage
- Test both success and error cases
- Test edge cases and boundary conditions
- Use mocks for external dependencies

## Pull Request Process

### Before Submitting

1. **Create a feature branch:**
```bash
git checkout -b feature/my-new-feature
```

2. **Make your changes:**
- Write code
- Add tests
- Update documentation

3. **Run all checks:**
```bash
uv run ruff check . && uv run ruff format --check . && uv run mypy && uv run pytest
```

4. **Commit your changes:**
```bash
git add .
git commit -m "Add my new feature"
```

Commit messages should:
- Use present tense ("Add feature" not "Added feature")
- Be clear and descriptive
- Reference issue numbers if applicable

5. **Push to your fork:**
```bash
git push origin feature/my-new-feature
```

### Submitting the PR

1. Open a Pull Request on GitHub
2. Fill out the PR template
3. Link any related issues
4. Wait for CI checks to pass
5. Address review feedback

### PR Requirements

- All tests must pass
- Code must pass linting and type checking
- New features must include tests
- Documentation must be updated

## Reporting Issues

### Bug Reports

When reporting bugs, please include:
- Description of the issue
- Steps to reproduce
- Expected behaviour
- Actual behaviour
- Python version
- Package version
- Minimal code example (if applicable)

### Feature Requests

When requesting features, please include:
- Clear description of the feature
- Use case and motivation
- Example API or usage (if applicable)
- Any alternatives you've considered

## Documentation

### Updating Documentation

- Update README.md for user facing changes
- Update docstrings for API changes
- Update CHANGELOG.md following Keep a Changelog format
- Add examples for new features

### Documentation Style

- Write clear, concise documentation
- Include code examples
- Explain the "why" not just the "what"
- Keep documentation up to date with code

## Release Process

Releases are managed by project maintainers:

1. Update version in `pyproject.toml`
2. Update `CHANGELOG.md`
3. Create git tag: `git tag -a v1.2.0 -m "Release v1.2.0"`
4. Push tag: `git push origin v1.2.0`
5. Build distributions: `uv build`
6. Upload to PyPI: `twine upload dist/*`

## Code of Conduct

- Be respectful and inclusive
- Focus on constructive feedback
- Help others learn and grow
- Assume good intentions

## Questions?

If you have questions about contributing:
- Open a [GitHub Issue](https://github.com/disguise-one/python-plugin/issues)
- Check existing issues and PRs
- Review the documentation

## License

By contributing, you agree that your contributions will be licensed under the MIT License.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 disguise
Copyright (c) 2025 Disguise Technologies ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading