Skip to content

Modernize pyMultiChange: Python 3.10+, Poetry, and CI/CD - #20

Merged
jtdub merged 4 commits into
masterfrom
claude/modernize-python-3.10-XW6vx
Jan 29, 2026
Merged

Modernize pyMultiChange: Python 3.10+, Poetry, and CI/CD#20
jtdub merged 4 commits into
masterfrom
claude/modernize-python-3.10-XW6vx

Conversation

@jtdub

@jtdub jtdub commented Jan 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR modernizes the pyMultiChange project by upgrading to Python 3.10+, migrating to Poetry for dependency management, implementing comprehensive code quality tooling, and establishing a robust CI/CD pipeline with GitHub Actions.

Key Changes

Project Structure & Packaging

  • Migrated from setup.py to pyproject.toml with Poetry configuration
  • Reorganized code from bin/multi_change.py to pymultichange/ package structure
  • Added py.typed marker for PEP 561 type hint support
  • Created proper package initialization with version and metadata

Code Quality & Linting

  • Added Ruff configuration (.ruff.toml) for fast linting and formatting
  • Added Pylint configuration (.pylintrc) with sensible defaults
  • Added MyPy configuration (mypy.ini) for strict type checking
  • Created Makefile with convenient development commands
  • All tools configured for Python 3.10+ with line length of 100 characters

Type Safety & Validation

  • Introduced Pydantic v2 models (pymultichange/models.py) for:
    • Input validation (command-line arguments)
    • Device configuration validation
    • Credentials management
    • Protocol enumeration
  • Refactored main script with full type hints and docstrings

Testing Infrastructure

  • Added pytest configuration in pyproject.toml
  • Created test fixtures in tests/conftest.py
  • Added test structure with proper imports
  • Configured coverage reporting with HTML output

CI/CD Pipeline

  • Created comprehensive GitHub Actions workflow (.github/workflows/ci.yml) with:
    • Linting jobs (Ruff, Pylint, MyPy) across Python 3.10, 3.11, 3.12
    • Test jobs with pytest and coverage reporting
    • Build verification job
    • Codecov integration for coverage tracking
    • Caching for Poetry dependencies
    • System dependency installation (libsnmp-dev, libffi-dev)

Issue Templates & Documentation

  • Added bug report template (.github/ISSUE_TEMPLATE/bug_report.md)
  • Added feature request template (.github/ISSUE_TEMPLATE/feature_request.md)
  • Added pull request template (.github/PULL_REQUEST_TEMPLATE.md)
  • Completely rewrote README with:
    • Modern badges (CI status, Python version, code style)
    • Comprehensive feature list
    • Detailed installation instructions
    • Complete usage examples
    • Development setup guide
    • Project structure documentation
    • Contributing guidelines

Dependency Management

  • Removed legacy Travis CI configuration (.travis.yml)
  • Updated .gitignore with comprehensive Python patterns
  • Configured Poetry with:
    • Core dependencies: pydantic, netlib
    • Dev dependencies: pytest, ruff, pylint, mypy, black, isort
    • Console script entry point: multi-change command

Code Improvements

  • Refactored main script with:
    • Proper error handling and logging
    • Type hints throughout
    • Comprehensive docstrings
    • Pydantic validation for all inputs
    • Better separation of concerns
    • Queue-based threading implementation
    • Path handling with pathlib

Notable Implementation Details

  • Backward Compatibility: The command-line interface remains largely unchanged, ensuring existing scripts continue to work
  • Logging: Implemented structured logging with debug and info levels
  • Error Handling: Improved error messages and failure logging
  • Type Safety: Full type hints enable IDE support and catch errors early
  • Testing Ready: Infrastructure in place for comprehensive test coverage
  • Python 3.10+: Leverages modern Python features (type unions, match statements ready)

Migration Notes

Users upgrading from the old version should:

  1. Install with Poetry: poetry install
  2. Use the new command: multi-change (instead of bin/multi_change.py)
  3. All command-line arguments remain the same
  4. Credentials are still stored in system keyring

https://claude.ai/code/session_01T84i3Yc4JoHK2ydKUcYm8P

This is a comprehensive modernization of the pyMultiChange project:

**Major Changes:**
- Migrated from setup.py to Poetry for package management
- Updated codebase to require Python 3.10+
- Added Pydantic v2 for robust input/output validation
- Configured netlib as direct GitHub dependency
- Removed all Python 2 compatibility code

**Testing & CI/CD:**
- Removed Travis CI configuration
- Added GitHub Actions workflow with multi-version testing (3.10, 3.11, 3.12)
- Implemented comprehensive pytest test suite with fixtures
- Added test coverage reporting
- Tests for Pydantic models and main application logic

**Code Quality:**
- Configured Ruff for fast, modern linting
- Added Pylint configuration for code quality checks
- Set up MyPy for static type checking
- Added type hints throughout codebase
- Replaced bare except clauses with proper error handling
- Modernized imports (removed __future__ imports)

**Developer Experience:**
- Added Makefile for common development tasks
- Created comprehensive README with examples and documentation
- Added py.typed marker for type checking support
- Included GitHub issue and PR templates
- Improved logging with proper configuration

**Code Structure:**
- Created pymultichange package with proper structure
- Separated concerns: models.py for Pydantic models
- Modernized multi_change.py with type hints and better error handling
- Used pathlib instead of os.path
- Proper use of queue module (no Python 2/3 compatibility hacks)

**Breaking Changes:**
- Minimum Python version is now 3.10
- Script now installed as 'multi-change' command via Poetry
- Old bin/multi_change.py and setup.py removed

https://claude.ai/code/session_01T84i3Yc4JoHK2ydKUcYm8P
- Replace Optional[X] with X | None syntax for Python 3.10+
- Remove unused imports (NoReturn, Optional, Generator)
- Fix import ordering to follow Ruff/isort conventions
- Separate standard library, third-party, and local imports

All changes ensure compatibility with Ruff linter configuration
and maintain Python 3.10+ modern syntax requirements.

https://claude.ai/code/session_01T84i3Yc4JoHK2ydKUcYm8P
Add second blank line after imports as required by Ruff isort
configuration (lines-after-imports = 2).

This ensures proper spacing between import blocks and the rest
of the code according to the project's Ruff linting standards.

https://claude.ai/code/session_01T84i3Yc4JoHK2ydKUcYm8P
Update all deprecated actions to their v4 versions:
- actions/cache@v3 → actions/cache@v4
- actions/upload-artifact@v3 → actions/upload-artifact@v4
- codecov/codecov-action@v3 → codecov/codecov-action@v4

This resolves the deprecation warnings from GitHub Actions
and ensures compatibility with the latest runner versions.

https://claude.ai/code/session_01T84i3Yc4JoHK2ydKUcYm8P
@jtdub
jtdub merged commit 8364b6a into master Jan 29, 2026
7 checks passed
@jtdub
jtdub deleted the claude/modernize-python-3.10-XW6vx branch January 29, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants