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 hints, fix mypy issues (#198) #228

Merged
merged 15 commits into from
Jul 1, 2024

Commits on Jun 28, 2024

  1. Update tox.ini for Django 3.2, pypy, gh

    * Specify how to install Django 3.2. These tests are currently running
      against later Django versions.
    * Add basepython entries for pypy. This fixes running tox locally.
    * Fix the cpython version mapping in [gh-actions]. The github action
      tests for cpython versions are running against the latest Django,
      instead of the set of possible Django versions.
    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    d2a460b View commit details
    Browse the repository at this point in the history
  2. Remove pypy from Django 3.2 testing

    There are a few test failures with pypy and Django 3.2. Since 3.2 is out
    of long-term support, drop these from the test matrix.
    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    f4f83ad View commit details
    Browse the repository at this point in the history
  3. Add mypy for type checking

    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    441fdf9 View commit details
    Browse the repository at this point in the history
  4. Handle case where config is None

    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    3acd7b7 View commit details
    Browse the repository at this point in the history
  5. Use getattr, setattr for dynamic attribute access

    mypy complains when reading or setting a attribute that is not defined
    on the class, such as HttpRequest.csp_nonce. This updates the code to
    use getattr and setattr to access these dynamically added attributes and
    for Django settings.
    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    5854441 View commit details
    Browse the repository at this point in the history
  6. Use tuples where requested

    Both startswith() and parser.parse_statements take a tuple rather than a
    list.
    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    abf8c1b View commit details
    Browse the repository at this point in the history
  7. Add type hints

    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    035844a View commit details
    Browse the repository at this point in the history
  8. Refactor ScriptTestBase

    Althought the code `template.render(context)` looked similar, mypy
    complained that Django's Template could not take a dict. Rather than
    switch on types, refactor `make_context` and `make_template` into
    `render`, which hides the typing details between Django templates and
    extension templates like Jinja2.
    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    932856e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    26c03b1 View commit details
    Browse the repository at this point in the history
  10. Add pip install -e ".[dev]"

    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    42125a5 View commit details
    Browse the repository at this point in the history
  11. Update docs for typing, etc.

    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    f247464 View commit details
    Browse the repository at this point in the history
  12. Add PEP 561 py.typed file

    jwhitlock authored and robhudson committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    0b728aa View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    c2a4317 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    0afd172 View commit details
    Browse the repository at this point in the history

Commits on Jul 1, 2024

  1. Update CHANGES file

    robhudson committed Jul 1, 2024
    Configuration menu
    Copy the full SHA
    a14b51c View commit details
    Browse the repository at this point in the history