Skip to content

Drop Terragrunt support and modernize Python codebase#89

Merged
ludoo merged 6 commits into
masterfrom
ludo/refactor
Mar 31, 2026
Merged

Drop Terragrunt support and modernize Python codebase#89
ludoo merged 6 commits into
masterfrom
ludo/refactor

Conversation

@ludoo

@ludoo ludoo commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

This PR introduces a major cleanup and modernization of the library. It strips out all Terragrunt-specific functionality to focus exclusively on Terraform and OpenTofu going forward. Additionally, it modernizes the Python codebase by adopting newer standard library features, adding type hints, and refactoring internal logic for better maintainability.

1. Removal of Terragrunt Support

  • Removed the TerragruntTest class and all associated tg_* arguments.
  • Removed all Terragrunt-specific test files (test_tg_all.py) and fixtures.
  • Updated README.md to remove Terragrunt documentation.
  • Impact: The library is now leaner and strictly focused on standard Terraform/OpenTofu workflows.

2. Python Modernization

  • Legacy Code Removal: Dropped Python 2 __future__ imports.
  • String Formatting: Migrated all legacy %s and .format() string formatting to modern f-strings.
  • Path Manipulation: Replaced os.path and glob usage with pathlib.Path for safer and more idiomatic file system operations.
  • Type Hinting: Added comprehensive type hints (typing) to TerraformTest public methods (plan, apply, init, etc.) to significantly improve IDE autocompletion and developer experience.

3. Internal Refactoring

  • Argument Parsing: Refactored the parse_args function. Replaced a massive block of if/elif statements with declarative dictionary mappings (bool_flags, inverse_bool_flags, kv_flags). This drastically reduces cyclomatic complexity and makes adding new Terraform CLI flags trivial in the future.

Testing

  • Cleaned up obsolete tests.
  • Verified that the remaining 90 tests pass successfully using pytest in an isolated virtual environment.

ludoo added 6 commits March 30, 2026 17:26
Strip out all Terragrunt-specific logic, arguments, and classes (e.g., TerragruntTest).
Remove Terragrunt test fixtures and associated test files (test_tg_all.py).
Clean up test_args.py to remove Terragrunt argument tests.
Update README.md to remove the Terragrunt documentation.

Going forward, this library will only support Terraform and OpenTofu.
- Remove legacy Python 2 future imports.
- Migrate string formatting to f-strings via flynt.
- Replace os.path usage with pathlib.Path.
- Add comprehensive type hinting to TerraformTest and related methods.
Replaced long list of if/elif statements with declarative mappings
(bool_flags, inverse_bool_flags, kv_flags) to simplify adding new
flags and reduce cyclomatic complexity.
Add .style.yapf using google style to match the Cloud Foundation
Fabric repository. Apply yapf formatting across all python files.
Replace autopep8 with yapf in the GitHub Actions linting workflow
and DEV-REQUIREMENTS.txt to enforce the new Google-style formatting
rules defined in .style.yapf.
@ludoo ludoo merged commit 4bbedb4 into master Mar 31, 2026
6 checks passed
@ludoo ludoo deleted the ludo/refactor branch March 31, 2026 06:04
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.

1 participant