Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type annotations #603

Merged
merged 28 commits into from
Jun 19, 2024
Merged

Add type annotations #603

merged 28 commits into from
Jun 19, 2024

Commits on Jun 13, 2024

  1. Configuration menu
    Copy the full SHA
    04e152f View commit details
    Browse the repository at this point in the history
  2. Call Field.get_default() instead of _get_default()

    We can call the inherited public method using `super()` instead of
    calling the private method directly.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    db93360 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    885da69 View commit details
    Browse the repository at this point in the history
  4. Enable postponed evaluation of annotations for all source modules

    This allows using the latest annotation syntax supported by the type
    checker regardless of the runtime Python version.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    0043fed View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    632441e View commit details
    Browse the repository at this point in the history
  6. Annotate the tracker module

    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    56ea527 View commit details
    Browse the repository at this point in the history
  7. Annotate the managers module

    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    bde2d8f View commit details
    Browse the repository at this point in the history
  8. Annotate the models module

    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    172cc72 View commit details
    Browse the repository at this point in the history
  9. Annotate the fields module

    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    ebfb345 View commit details
    Browse the repository at this point in the history
  10. Annotate the choices module

    The `Choices` constructor actually only accepts lists and tuples, not
    arbitrary sequences. However, using `list` in the annotation opens
    a can of worms related to type variance.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    2b0b482 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    713a3fe View commit details
    Browse the repository at this point in the history
  12. Enable postponed evaluation of annotations for all test modules

    This allows using the latest annotation syntax supported by the type
    checker regardless of the runtime Python version.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    aeeb69a View commit details
    Browse the repository at this point in the history
  13. Add minimal annotations to unit tests

    These annotations are sufficient to pass mypy inspection if mypy is
    configured to allow unannotated functions.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    218843d View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    23f1811 View commit details
    Browse the repository at this point in the history
  15. Annotate test helpers

    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    c83ef89 View commit details
    Browse the repository at this point in the history
  16. Annotate the test_choices module

    This required a bit of refactoring to get the type of `STATUS` correct
    for each suite.
    
    There are two cases which I decided not to support in the type system:
    - passing a list instead of a tuple when defining an option group
    - `in` checks using a data type that doesn't match the choices
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    9d3940a View commit details
    Browse the repository at this point in the history
  17. Add pytest to type check dependencies

    We also type check the unit tests and the unit tests now import
    functionality from pytest.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    e4c8810 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    949d110 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    7d6cad0 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    ecc7312 View commit details
    Browse the repository at this point in the history
  21. Drop uses of JoinManager from the tests

    The `JoinManager` class is deprecated and not annotated.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    3c31423 View commit details
    Browse the repository at this point in the history
  22. Suppress mypy errors in field tracker tests

    I can't find a way to inform mypy of the actual types without
    duplicating a lot of test code.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    8f0b4ee View commit details
    Browse the repository at this point in the history
  23. Annotate test_fields package

    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    23a756e View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    f4653f0 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    1db7d6b View commit details
    Browse the repository at this point in the history
  26. Add type argument to DescriptorWrapper

    This preserves the type of the wrapped descriptor (usually a field).
    
    Maybe this is overkill, as `DescriptorWrapper` seems to only be used
    as part of the `FieldTracker` implementation and is not documented
    and barely tested. But technically, it is public API.
    mthuurne committed Jun 13, 2024
    Configuration menu
    Copy the full SHA
    0093760 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    5fc37eb View commit details
    Browse the repository at this point in the history

Commits on Jun 14, 2024

  1. Tell coverage tool to ignore lines intended for mypy only

    In particular, `if TYPE_CHECKING:` blocks and `...` in bodies of
    overloaded method definitions.
    mthuurne committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    9dc2247 View commit details
    Browse the repository at this point in the history