Skip to content

feat(2to3)!: update to Python 3 and HyLang 1.2.0#34

Merged
ncouture merged 25 commits intomainfrom
feat/2to3-cleanup
Apr 24, 2026
Merged

feat(2to3)!: update to Python 3 and HyLang 1.2.0#34
ncouture merged 25 commits intomainfrom
feat/2to3-cleanup

Conversation

@ncouture
Copy link
Copy Markdown
Owner

Modernize project structure, build system, and toolchain

  • Migrate from setup.py/requirements.txt to pyproject.toml (PEP 621)
  • Migrate test suite from unittest to pytest and pytest-twiste d
  • Replace yapf with ruff for linting and formatting
  • Add mypy for static type checking and initial type annotations in MockSSH.py
  • Update Hy DSL and examples for compatibility with modern Hy versions
  • Add docs/wiki as a git submodule for project documentation
  • Overhaul Makefile to support virtual environments and the new toolchain
  • Implement pre-commit hooks for automated ruff and mypy checks

Modernize project structure, build system, and toolchain

  - Migrate from setup.py/requirements.txt to pyproject.toml (PEP 621)
  - Migrate test suite from unittest to pytest and pytest-twiste d
  - Replace yapf with ruff for linting and formatting
  - Add mypy for static type checking and initial type annotations in MockSSH.py
  - Update Hy DSL and examples for compatibility with modern Hy versions
  - Add docs/wiki as a git submodule for project documentation
  - Overhaul Makefile to support virtual environments and the new toolchain
  - Implement pre-commit hooks for automated ruff and mypy checks
Introduces GitHub Actions workflows and Gemini CLI command configurations to
automate issue triage, pull request reviews, and plan execution. Adds a
GEMINI.md file to provide project-specific context for the AI agent.

  - Create workflows for dispatch, invoke, plan-execute, review, and triage.
  - Define Gemini command templates in .github/commands/.
  - Add GEMINI.md with project architecture and development conventions.
  - Update .gitignore to ignore .gemini/ directory and credentials.
@ncouture ncouture requested a review from Copilot April 19, 2026 05:14
@ncouture ncouture self-assigned this Apr 19, 2026
@ncouture ncouture added bug enhancement python Pull requests that update python code labels Apr 19, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modernizes the MockSSH library by migrating it to Python 3.12+, adopting pyproject.toml for build management, and replacing unittest with pytest. Key changes include the addition of type hints, updated SSH security configurations (ciphers/MACs), and a transition from pycrypto to the cryptography library for host key generation. Feedback highlights critical race conditions in command instantiation, invalid dependency version constraints in the project configuration, and the use of mutable default arguments. Additionally, improvements were suggested regarding error handling in library functions and the removal of debug print statements.

Comment thread MockSSH.py Outdated
Comment thread MockSSH.py Outdated
Comment thread pyproject.toml
Comment thread src/MockSSH.py Outdated
Comment thread src/MockSSH.py Outdated
Comment thread src/MockSSH.py Outdated
Comment thread tests/test_mock_hy.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Modernizes MockSSH for a Python 3 / modern tooling workflow, including packaging, lint/type-check automation, updated Hy DSL support, and a pytest-based test suite.

Changes:

  • Migrates packaging/build metadata to pyproject.toml and updates development workflow (Makefile, pre-commit, Ruff/mypy).
  • Updates core MockSSH server implementation for Python 3, newer Twisted/Paramiko expectations, and new host key generation.
  • Reworks tests and examples for pytest + updated Hy DSL/macros.

Reviewed changes

Copilot reviewed 19 out of 23 changed files in this pull request and generated 21 comments.

Show a summary per file
File Description
tests/test_mock_hy.py Adds an end-to-end test that runs the Hy example server in a subprocess and validates SSH interaction.
tests/test_mock_cisco.py Migrates Cisco example tests from unittest to pytest with fixtures and Paramiko interaction.
tests/test_mock_F5.py Migrates F5 example tests from unittest to pytest with fixtures and Paramiko interaction.
tests/conftest.py Introduces a session-scoped autouse fixture to run the Twisted reactor in a background thread.
tests/__init__.py Test package marker (no functional changes).
test_macros.hy Adds a Hy macro file at repo root (appears currently unreferenced).
setup.py (removed) Removes legacy setuptools build script.
requirements.txt (removed) Removes legacy requirements pin file.
pyproject.toml Adds PEP 621-style project metadata, dependencies, and tool configuration (pytest/ruff/mypy).
mocksshy/language.hy Updates Hy DSL macros to modern Hy syntax and updated MockSSH API expectations.
mocksshy/kwzip.hy Updates Hy helper utilities (keyword detection, grouping logic) for modern Hy models.
generated-keys/.gitkeep Ensures the default host-key directory exists in git.
examples/mock_cisco.py Updates example code formatting/strings for Python 3 and current MockSSH API usage.
examples/mock_F5.py Updates example code formatting/strings for Python 3 and current MockSSH API usage.
examples/mock.hy Updates Hy example to use new require style and dict access patterns.
README.md Updates installation/dev instructions, mentions pytest/pytest-twisted, and updates license/docs notes.
MockSSH.py Major Python 3 update: typing, modern key generation, updated Twisted integration, threading helpers.
Makefile Replaces yapf workflow with Ruff + mypy targets; updates build/test commands; adds key cleanup.
.style.yapf (removed) Removes yapf config (replaced by Ruff).
.pre-commit-config.yaml Adds pre-commit hooks for Ruff and mypy.
.gitmodules Adds docs/wiki git submodule configuration.
.gitignore Adds venv ignore entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_mock_hy.py
Comment thread src/MockSSH.py Outdated
Comment thread src/MockSSH.py
Comment thread src/MockSSH.py Outdated
Comment thread tests/test_mock_hy.py Outdated
Comment thread tests/test_mock_F5.py
Comment thread tests/test_mock_F5.py Outdated
Comment thread .gitmodules Outdated
Comment thread pyproject.toml
Comment thread tests/test_mock_hy.py
@ncouture ncouture linked an issue Apr 19, 2026 that may be closed by this pull request
@ncouture ncouture moved this to Backlog in MockSSH Project Apr 19, 2026
@ncouture ncouture moved this from Backlog to In progress in MockSSH Project Apr 19, 2026
ncouture and others added 9 commits April 19, 2026 02:17
Updates documentation and build configuration to support Gemini-powered
automation and resolves testing warnings. Adds local pre-commit hooks to
ensure build and test integrity.

- Update GEMINI.md and README.md with details on AI-powered automation.
- Fix Makefile's clean_keys target to correctly handle generated-keys/.
- Resolve PytestUnknownMarkWarning by adding pytest-timeout to pyproject.toml.
- Add local pre-commit hooks for 'make tests' and 'make clean'.
Fixed a critical race condition in PromptingCommand and
ArgumentValidatingCommand by returning a new instance on each call to
prevent state leakage between concurrent sessions.

- Added a native HyLang test for the MockSSH
- DSL (tests/hy_dsl_test.hy) and updated conftest.py for HyLang
  ssupport
- Improved test coverage for Cisco and F5 mock examples
- New test cases for failure modes, edge cases, and interactive
  commands
- Resolved testing warnings (PytestUnknownMarkWarning)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…2.0.0

delete secret

chore: update licence details, authors, update to LGPL V3
@ncouture ncouture marked this pull request as draft April 19, 2026 19:56
@ncouture ncouture marked this pull request as ready for review April 19, 2026 19:57
ncouture and others added 2 commits April 19, 2026 17:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ncouture
Copy link
Copy Markdown
Owner Author

/gemini summary

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

This pull request represents a comprehensive modernization of the MockSSH project. The primary goal is to transition the codebase to modern Python standards, improve maintainability through static analysis and automated testing, and integrate advanced AI-driven development workflows. These changes enhance the project's robustness, security, and developer experience while maintaining compatibility with existing DSL features.

Highlights

  • Project Modernization: Migrated from setup.py to pyproject.toml (PEP 621) and updated the toolchain to Python 3.12+.
  • Testing Infrastructure: Replaced unittest with pytest and pytest-twisted, and implemented a custom test harness for managing the Twisted reactor.
  • Code Quality & Automation: Adopted Ruff for linting/formatting, added mypy for static type checking, and implemented pre-commit hooks.
  • AI Integration: Integrated Gemini CLI for automated issue triage, PR reviews, and autonomous plan execution.
Ignored Files
  • Ignored by pattern: .github/workflows/** (7)
    • .github/workflows/gemini-dispatch.yml
    • .github/workflows/gemini-invoke.yml
    • .github/workflows/gemini-plan-execute.yml
    • .github/workflows/gemini-review.yml
    • .github/workflows/gemini-scheduled-triage.yml
    • .github/workflows/gemini-triage.yml
    • .github/workflows/release-please.yml
Activity
  • The author requested a summary of the pull request.
  • Multiple review threads were opened by the AI agent and Copilot, identifying issues such as race conditions in command instances, version constraint inaccuracies, and test harness improvements.
  • The author addressed several review comments, including fixing race conditions in command classes and updating test subprocess handling.
  • The author engaged in discussions regarding the architectural choices for the test suite and the use of pytest-twisted.

@ncouture
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modernizes MockSSH for Python 3.12+, adopting a pyproject.toml build system, pytest with pytest-twisted, and Ruff/mypy for quality control. It also adds Gemini CLI automation for project workflows. Feedback focuses on securing generated host key file permissions, removing duplicated prompt instructions, transitioning from print() to proper logging, and aligning advertised SSH ciphers and host keys with the actual implementation.

Comment thread src/MockSSH.py Outdated
Comment thread .github/commands/gemini-invoke.toml
Comment thread src/MockSSH.py Outdated
Comment thread src/MockSSH.py
Comment thread src/MockSSH.py
Comment thread src/MockSSH.py
Copilot AI and others added 2 commits April 24, 2026 12:30
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ncouture ncouture merged commit 8bea005 into main Apr 24, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in MockSSH Project Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug enhancement python Pull requests that update python code

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

chore(update)!: Port to Python3, Hylang 1.2.0

3 participants