beda-software / drf-writable-nested

Writable nested model serializer for Django REST Framework
Other
1.07k stars 115 forks source link

Fix mypy checks #184

Open browniebroke opened 9 months ago

browniebroke commented 9 months ago

I think that the mypy tests are broken (See #183), so fixing them here before.

codecov-commenter commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (6b24fae) 98.23% compared to head (dcdd232) 98.23%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #184 +/- ## ======================================= Coverage 98.23% 98.23% ======================================= Files 3 3 Lines 227 227 ======================================= Hits 223 223 Misses 4 4 ``` | [Flag](https://app.codecov.io/gh/beda-software/drf-writable-nested/pull/184/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=beda-software) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/beda-software/drf-writable-nested/pull/184/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=beda-software) | `98.23% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=beda-software#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

browniebroke commented 9 months ago

Looks like the failures are for older version of Django (3.1):

py311-dj31-drf314-mypy: commands[0]> mypy example
  /home/runner/work/drf-writable-nested/drf-writable-nested/.tox/py311-dj31-drf314-mypy/lib/python3.11/site-packages/django/utils/encoding.py:266: DeprecationWarning: 'locale.getdefaultlocale' is deprecated and slated for removal in Python 3.15. Use setlocale(), getencoding() and getlocale() instead.
    encoding = locale.getdefaultlocale()[1] or 'ascii'
  /home/runner/work/drf-writable-nested/drf-writable-nested/.tox/py311-dj31-drf314-mypy/lib/python3.11/site-packages/django-stubs/contrib/sites/models.pyi:13: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
  https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
  If this issue continues with mypy master, please report a bug at [https://github.com/python/mypy/issues](https://github.com/python/mypy/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
  version: 1.7.1
  /home/runner/work/drf-writable-nested/drf-writable-nested/.tox/py311-dj31-drf314-mypy/lib/python3.11/site-packages/django-stubs/contrib/sites/models.pyi:13: : note: please use --show-traceback to print a traceback when reporting a bug
  py311-dj31-drf314-mypy: exit 2 (1.35 seconds) /home/runner/work/drf-writable-nested/drf-writable-nested> mypy example pid=2330
py311-dj31-drf314-mypy: FAIL ✖ in 8.22 seconds

The latest versions of django-stubs and djangorestframework-stubs are for a specific version of Django and DRF, so I feel like we shouldn't type check for older versions... Thoughts?

browniebroke commented 9 months ago

Alternatively, drop support for Django <3.2, which has been long unsupported:

image
browniebroke commented 9 months ago

Tests are now passing, but it fails to upload to codecov... It seems unrelated to my change, but if someone can help resolving this, that would be appreciated. Thanks