Description
This issue focuses on enhancing the code quality and maintainability of the ai-bom project by adding Python type hints to the scanner module. Type hints improve code readability, help catch potential errors during development, and enable better tooling support (e.g., static analysis).
Acceptance Criteria
- All functions and methods within the
ai_bom/scanner.py file have been annotated with appropriate type hints.
- Type hints cover function arguments, return values, and variable assignments where applicable and beneficial.
- The codebase passes type checking using
mypy without any errors or warnings.
- Existing unit tests still pass after adding type hints.
- The added type hints are consistent with the existing codebase and Python best practices.
Suggested Approach
- Set up your development environment:
- Clone the
ai-bom repository.
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
source venv/bin/activate (Linux/macOS) or venv\Scripts\activate (Windows)
- Install the development dependencies, including
mypy: pip install -e .[dev]
- Explore the
ai_bom/scanner.py file:
- Understand the functionality of each function and class within the module.
- Add type hints:
- Start adding type hints to function arguments and return values. For example:
def scan_directory(directory: str) -> list[str]:
# ...
- Add type hints to variables within functions where it improves clarity.
- Use
Any type hint sparingly and only when the type cannot be determined.
- Run
mypy to check for type errors:
- Execute
mypy ai_bom/scanner.py in the terminal.
- Fix any errors reported by
mypy.
- Repeat steps 3 and 4 until
mypy reports no errors.
- Run existing unit tests:
- Execute
pytest in the terminal.
- Ensure all tests pass after adding type hints. Fix any failing tests if necessary.
- Commit and create a pull request:
- Commit your changes with a clear message (e.g., "feat: Add type hints to scanner module").
- Create a pull request to the
main branch.
Additional Context
The scanner module is responsible for discovering and analyzing components within AI/ML projects. It's a critical part of ai-bom, so adding type hints will significantly improve its maintainability. Make sure to refer to the Python documentation on type hints for more information: https://docs.python.org/3/library/typing.html. If you are unsure about the correct type hint to use, feel free to ask for clarification in the pull request.
Description
This issue focuses on enhancing the code quality and maintainability of the
ai-bomproject by adding Python type hints to thescannermodule. Type hints improve code readability, help catch potential errors during development, and enable better tooling support (e.g., static analysis).Acceptance Criteria
ai_bom/scanner.pyfile have been annotated with appropriate type hints.mypywithout any errors or warnings.Suggested Approach
ai-bomrepository.python -m venv venvsource venv/bin/activate(Linux/macOS) orvenv\Scripts\activate(Windows)mypy:pip install -e .[dev]ai_bom/scanner.pyfile:Anytype hint sparingly and only when the type cannot be determined.mypyto check for type errors:mypy ai_bom/scanner.pyin the terminal.mypy.mypyreports no errors.pytestin the terminal.mainbranch.Additional Context
The
scannermodule is responsible for discovering and analyzing components within AI/ML projects. It's a critical part ofai-bom, so adding type hints will significantly improve its maintainability. Make sure to refer to the Python documentation on type hints for more information: https://docs.python.org/3/library/typing.html. If you are unsure about the correct type hint to use, feel free to ask for clarification in the pull request.