Description
This issue aims to improve the code quality and maintainability of the ai_bom.scanner module by adding Python type hints. Type hints make the code easier to understand, debug, and refactor, especially for new contributors.
The ai_bom.scanner module is responsible for scanning AI/ML projects and gathering information about their dependencies and components. Adding type hints to this module will clarify the expected input and output types of its functions and classes.
Acceptance Criteria
- All functions and methods within the
ai_bom.scanner module have complete and accurate type hints, including: argument types, return types, and variable types.
- The code should still pass all existing unit tests after adding type hints. If any tests fail due to type hints, update the tests accordingly.
- The type hints should be PEP 484 compliant.
- The code should be formatted with a tool like
black or ruff after adding type hints.
- No new dependencies should be introduced.
Suggested Approach
- Familiarize yourself with the
ai_bom.scanner module: Read the code in ai_bom/scanner.py to understand its structure and functionality.
- Add type hints: Start by adding type hints to the function arguments and return values. Then, add type hints to local variables where necessary.
- Run type checker: Use a type checker like
mypy to verify the correctness of the type hints. Run mypy ai_bom/scanner.py (you might need to install mypy first pip install mypy).
- Address type errors: If
mypy reports any errors, correct the type hints or the code to resolve them.
- Run unit tests: Ensure that all existing unit tests still pass after adding type hints. Run
pytest from the project root.
- Format the code: Use a code formatter like
black or ruff to ensure consistent code style. Run black ai_bom/scanner.py or ruff format ai_bom/scanner.py.
- Commit and create a pull request: Commit your changes with a descriptive message and create a pull request.
Additional Context
- If you are new to Python type hints, refer to the official Python documentation: https://docs.python.org/3/library/typing.html
- Feel free to ask questions and seek help from the project maintainers if you encounter any difficulties.
- The existing codebase might already use type hints partially, please be consistent and complete the process for the entire module.
Description
This issue aims to improve the code quality and maintainability of the
ai_bom.scannermodule by adding Python type hints. Type hints make the code easier to understand, debug, and refactor, especially for new contributors.The
ai_bom.scannermodule is responsible for scanning AI/ML projects and gathering information about their dependencies and components. Adding type hints to this module will clarify the expected input and output types of its functions and classes.Acceptance Criteria
ai_bom.scannermodule have complete and accurate type hints, including: argument types, return types, and variable types.blackorruffafter adding type hints.Suggested Approach
ai_bom.scannermodule: Read the code inai_bom/scanner.pyto understand its structure and functionality.mypyto verify the correctness of the type hints. Runmypy ai_bom/scanner.py(you might need to install mypy firstpip install mypy).mypyreports any errors, correct the type hints or the code to resolve them.pytestfrom the project root.blackorruffto ensure consistent code style. Runblack ai_bom/scanner.pyorruff format ai_bom/scanner.py.Additional Context