Skip to content

Add Python Type Hints to the sbom_generator module #61

@Zie619

Description

@Zie619

Description

This issue is to add Python type hints to the ai_bom/sbom_generator.py module. Adding type hints improves code readability, maintainability, and helps catch potential errors during development. This is a great first issue for someone new to the project and type hinting in Python.

Acceptance Criteria

  • The ai_bom/sbom_generator.py file should have complete type hints for all functions, methods, and variables where applicable.
  • The code should pass type checking using mypy with no errors or warnings. We might need to adjust our mypy configuration in pyproject.toml if necessary to allow for certain patterns.
  • The changes should not introduce any new runtime errors or break existing functionality.
  • The code should still adhere to the project's coding style.

Suggested Approach

  1. Set up your development environment:
    • Fork the ai-bom repository.
    • Clone your forked repository to your local machine.
    • Set up a virtual environment (e.g., using venv or conda).
    • Install the project dependencies using pip install -e ..
    • Install mypy using pip install mypy.
  2. Familiarize yourself with the sbom_generator.py module:
    • Read the code and understand its purpose and functionality. Pay close attention to the function signatures and data structures used.
  3. Add type hints:
    • Starting from the top of the file, add type hints to function arguments, return values, and variables.
    • Use appropriate types from the typing module (e.g., List, Dict, Optional, Union) where necessary.
    • Run mypy ai_bom/sbom_generator.py to check for type errors. Address any errors or warnings reported by mypy.
  4. Run existing tests:
    • Run the existing tests to ensure that your changes haven't broken any functionality. Use pytest.
    • If tests fail, debug and fix the issues.
  5. Commit and push your changes:
    • Commit your changes with a descriptive commit message (e.g., "feat: Add type hints to sbom_generator.py").
    • Push your changes to your forked repository.
  6. Create a pull request:
    • Create a pull request from your forked repository to the main ai-bom repository.
    • In the pull request description, explain the changes you've made and reference this issue.

Additional Context

  • Refer to the Python documentation on type hints: https://docs.python.org/3/library/typing.html
  • Consider using a code editor or IDE with built-in type checking support (e.g., VS Code with the Python extension, PyCharm).
  • Don't hesitate to ask questions on the issue if you're unsure about anything!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions