This document provides detailed instructions for developing and publishing the argparse-ps1 package using modern Python tooling with uv.
- uv - Fast Python package manager
- Python 3.11+ (uv will manage Python versions for you)
# Clone the repository
git clone https://github.com/shimarch/argparse-ps1.git
cd argparse-ps1
# Install in development mode with dependencies
uv sync --all-extrasThis package includes type annotations and a py.typed file to support static type checking with tools like Pylance, mypy, and other type checkers.
Type checker setup:
- The package is marked as typed with
py.typedfile - VS Code/Pylance configuration is included in
.vscode/settings.json - Package metadata includes
"Typing :: Typed"classifier
Resolving type stub warnings:
If you see "stub file not found" warnings in Pylance:
- Ensure the package is installed in development mode:
uv pip install -e . - Restart VS Code language server:
Ctrl+Shift+P→ "Python: Restart Language Server" - Check that
py.typedexists insrc/argparse_ps1/
# Run all tests
uv run python -m pytest tests/ -v
# Run tests with coverage
uv run python -m pytest tests/ -v --cov=argparse_ps1 --cov-report=html
# Run specific test
uv run python -m pytest tests/test_argparse_ps1.py::test_import -v
# Run tests with coverage report
uv run python -m pytest tests/ -v --cov=argparse_ps1 --cov-report=termCode quality checks are automatically enforced by pre-commit hooks. You can also run them manually:
# Format code with black
uv run black src tests examples
# Lint with ruff
uv run ruff check src tests examples
# Fix linting issues automatically
uv run ruff check --fix src tests examples
# Format with ruff
uv run ruff format src tests examples
# Run all checks
uv run ruff check src tests examples
uv run black --check src tests examples
uv run ruff format --check src tests examplesNote: These checks run automatically on every commit via pre-commit hooks.
Pre-commit hooks ensure code quality before each commit by automatically running formatters and linters.
# Install pre-commit hooks (one-time setup)
uv run pre-commit install
# Run pre-commit on all files manually
uv run pre-commit run --all-files
# Pre-commit hooks will automatically run on each git commit
# If hooks fail, fix the issues and commit againWhen ready to release a new version:
-
Update version in
pyproject.toml:[project] name = "argparse-ps1" version = "0.1.3" # Increment version following semantic versioning
-
Update version in source code (if applicable):
# In src/argparse_ps1/__init__.py __version__ = "0.1.3"
# After making changes and updating version
git add .
git commit -m "Bump version to 0.1.3 and add new features"
git push origin mainResult: GitHub Actions automatically publishes to TestPyPI for testing.
# Create and push a version tag for production release
git tag v0.1.3
git push origin v0.1.3Result: GitHub Actions automatically publishes to production PyPI.
# Test installation from TestPyPI
uv pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ argparse-ps1
# Verify functionality
python -c "from argparse_ps1 import generate_ps1_wrapper; print('TestPyPI installation successful!')"# Check if package is available on PyPI
uv pip install argparse-ps1
# Verify installation
python -c "from argparse_ps1 import generate_ps1_wrapper; print('PyPI installation successful!')"
# Check package information
pip show argparse-ps1# Clean and build package
uv build --clean
# Check distribution quality
uv run twine check dist/*
# Test wheel contents
python -m zipfile -l dist/*.whl
# Manual upload to TestPyPI (if needed)
uv run twine upload --repository testpypi dist/*
# Manual upload to PyPI (if needed)
uv run twine upload dist/*Clean build artifacts when you encounter build issues or need a fresh build environment.
When to clean:
- Build errors or inconsistent builds
- When switching between development and production builds
- After making changes to
pyproject.toml - Troubleshooting import or packaging issues
# Clean all build artifacts
rm -rf build/ dist/ *.egg-info/
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete