-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
Description
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.scannermodule 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
blackorruffafter adding type hints. - No new dependencies should be introduced.
Suggested Approach
- Familiarize yourself with the
ai_bom.scannermodule: Read the code inai_bom/scanner.pyto 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
mypyto verify the correctness of the type hints. Runmypy ai_bom/scanner.py(you might need to install mypy firstpip install mypy). - Address type errors: If
mypyreports 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
pytestfrom the project root. - Format the code: Use a code formatter like
blackorruffto ensure consistent code style. Runblack ai_bom/scanner.pyorruff 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.
Reactions are currently unavailable