ua-generator icon indicating copy to clipboard operation
ua-generator copied to clipboard

Add Mypy Support and Improve Type Hinting

Open plasenca-d opened this issue 6 months ago • 4 comments

This PR introduces static type checking support using Mypy and enhances the overall type hinting throughout the ua-generator library.

Key Changes:

  • Added py.typed marker file: Includes the py.typed file in the src/ua_generator directory to signal PEP 561 compliance, allowing Mypy to recognize the package for type checking.
  • Introduced Mypy Test: Added a new test file test_typing.py specifically for verifying type hints with Mypy. This includes instructions on how to run the check.
  • Enhanced Type Annotations:
    • Added type hints to function signatures, return types, and variables across various modules, including utils.py , client_hints.py , options.py , and data modules within data .
    • Utilized types from the typing module like List , Dict , Union , Literal , and Any for better code clarity and correctness.
    • Improved type definitions within the Version class and its subclasses ( ChromiumVersion , AndroidVersion , WindowsVersion ).

These changes improve code maintainability, reduce potential runtime errors, and make the library easier to use correctly by providing clearer type information.

plasenca-d avatar Apr 27 '25 18:04 plasenca-d