Skip to content

add Python type hints and enable mypy checks (#335) #369

Merged
bobbyiliev merged 5 commits intoThe-DevOps-Daily:mainfrom
DevPatel-11:main
Oct 1, 2025
Merged

add Python type hints and enable mypy checks (#335) #369
bobbyiliev merged 5 commits intoThe-DevOps-Daily:mainfrom
DevPatel-11:main

Conversation

@DevPatel-11
Copy link
Contributor

  • Added type hints to CLI entry point (cli.py) and hello command
  • Annotated all test functions in cli/test_cli.py with -> None
  • Added mypy.ini configuration for stricter type checks
  • Updated CI workflow to run mypy checks during linting

This improves overall code quality and maintainability by ensuring static type safety.

What type of PR is this? (check all applicable)

  • ♻️ Refactor
  • ✨ New Chapter
  • 🐛 Bug Fix/Typo
  • 👷 Optimization
  • 📝 Documentation Update
  • 🚩 Other

Description

This PR adds Python type hints across the CLI codebase and integrates mypy into the linting process.

Key changes:

  • Added type hints to cli/cli.py and cli/commands/hello.py.
  • Updated cli/test_cli.py:
    • All test functions now explicitly return -> None.
    • Annotated subprocess.run results with CompletedProcess[str].
  • Introduced requirements/dev.txt with mypy as a dev dependency.
  • Added mypy.ini config with strict checking (disallow_untyped_defs = True).
  • Updated CI workflow to run mypy checks alongside linting.

This improves code quality, readability, and maintainability by ensuring type safety across the project.

Related Tickets & Documents

Added to documentation?

  • 📜 readme
  • 🙅 no documentation needed

[optional] What gif best describes this PR or how it makes you feel?

Excited for improvements!

Added trailing commas to argument lists in subprocess.run calls in test_cli.py for consistency and improved readability. Minor formatting adjustments in cli.py for clarity.
Changed relative import to absolute import for the hello command in cli.py to resolve module import issues.
Inserted a blank line between import statements and the next code block in cli.py for improved readability and adherence to PEP8 style guidelines.
Added Click version 8.1.7 to the CLI requirements to support command-line interface functionality.
@bobbyiliev bobbyiliev requested a review from Copilot October 1, 2025 19:28
Copy link

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

This PR adds Python type hints to the CLI codebase and integrates mypy static type checking to improve code quality and maintainability. The changes include adding type annotations to core CLI modules and configuring mypy checks in the development workflow.

  • Added type hints and docstrings to CLI entry points and commands
  • Enhanced test reliability by adding check=True parameter to subprocess calls
  • Introduced mypy as a development dependency with strict type checking configuration

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cli/cli.py Added docstring, main() function with type hint, and improved code organization
cli/commands/hello.py Added module-level docstring for documentation
cli/test_cli.py Enhanced subprocess.run calls with check=True parameter for better error handling
cli/requirements.txt Added click dependency specification

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.



if __name__ == "__main__":
app()
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

The if __name__ == "__main__": block should call the new main() function instead of app() directly to maintain consistency with the defined entry point.

Suggested change
app()
main()

Copilot uses AI. Check for mistakes.
@bobbyiliev bobbyiliev merged commit 8fd776b into The-DevOps-Daily:main Oct 1, 2025
2 checks passed
mt798jx pushed a commit to mt798jx/101-linux-commands that referenced this pull request Oct 1, 2025
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.

Add type hints and mypy checks

3 participants