profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/tomchristie/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Tom Christie tomchristie Encode OSS Brighton, UK http://www.tomchristie.com/ 🌼

encode/django-rest-framework 21916

Web APIs for Django. 🎸

encode/apistar 5591

The Web API toolkit. 🛠

encode/uvicorn 4370

The lightning-fast ASGI server. 🦄

encode/rest-framework-tutorial 1034

The Django REST framework tutorial. 🎓

encode/django-vanilla-views 896

Beautifully simple class-based views.

HassenPy/django-pdb 387

Gives you `manage.py runserver --pdb` and `manage.py test --pdb`

tomchristie/mkautodoc 150

Auto documentation for MkDocs 📘

andrew-d/python-multipart 89

A streaming multipart parser for Python.

tomchristie/express-browsable-api 81

Browsable Web APIs for Node.js / Express.

encode/dashboard 60

An admin interface for ASGI Web frameworks.

pull request commentencode/django-rest-framework

Clear Sphinx warnings from serializers.

We don't use Sphinx for the REST framework docs, tho?...

derekwisong

comment created time in 8 hours

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         super().setUpClass()         assert urlpatterns is cls.urlpatterns -    @classmethod-    def tearDownClass(cls):-        assert urlpatterns is cls.urlpatterns-        super().tearDownClass()-        assert urlpatterns is not cls.urlpatterns+        if django.VERSION > (4, 0):+            cls.addClassCleanup(+                check_urlpatterns,+                cls+            )++    if django.VERSION < (4, 0):+        @classmethod+        def tearDownClass(cls):+            assert urlpatterns is cls.urlpatterns+            super().tearDownClass()+            assert urlpatterns is not cls.urlpatterns

My suspicion it's the timing on the override_settings usage — which is always delicate, as we know from e.g. #5668 &friends.

Yes that seems very likely.

carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         super().setUpClass()         assert urlpatterns is cls.urlpatterns -    @classmethod-    def tearDownClass(cls):-        assert urlpatterns is cls.urlpatterns-        super().tearDownClass()-        assert urlpatterns is not cls.urlpatterns+        if django.VERSION > (4, 0):+            cls.addClassCleanup(+                check_urlpatterns,+                cls+            )++    if django.VERSION < (4, 0):+        @classmethod+        def tearDownClass(cls):+            assert urlpatterns is cls.urlpatterns+            super().tearDownClass()+            assert urlpatterns is not cls.urlpatterns

Once super().setUpClass() is moved in rest_framework/test.py this class doesn't need to change at all. (Or at least, that's how it seems from my testing.)

carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         cls._module.urlpatterns = cls.urlpatterns          cls._override.enable()++        if django.VERSION > (4, 0):+            cls.addClassCleanup(cls._override.disable)+            cls.addClassCleanup(cleanup_url_patterns, cls)

In other words, this works...

    @classmethod
    def setUpClass(cls):
        super().setUpClass()  # <--- This line has moved.

        # Get the module of the TestCase subclass
        cls._module = import_module(cls.__module__)
        cls._override = override_settings(ROOT_URLCONF=cls.__module__)

        if hasattr(cls._module, 'urlpatterns'):
            cls._module_urlpatterns = cls._module.urlpatterns

        cls._module.urlpatterns = cls.urlpatterns

        cls._override.enable()

    @classmethod
    def tearDownClass(cls):
        super().tearDownClass()
        cls._override.disable()

        if hasattr(cls, '_module_urlpatterns'):
            cls._module.urlpatterns = cls._module_urlpatterns
        else:
            del cls._module.urlpatterns
carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         cls._module.urlpatterns = cls.urlpatterns          cls._override.enable()++        if django.VERSION > (4, 0):+            cls.addClassCleanup(cls._override.disable)+            cls.addClassCleanup(cleanup_url_patterns, cls)

Moving super().setUpClass() from the bottom of the setUpClass method to the top resolves this without any 4.0 branching.

Do I properly understand why? Nope.

carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         super().setUpClass()         assert urlpatterns is cls.urlpatterns -    @classmethod-    def tearDownClass(cls):-        assert urlpatterns is cls.urlpatterns-        super().tearDownClass()-        assert urlpatterns is not cls.urlpatterns+        if django.VERSION > (4, 0):+            cls.addClassCleanup(+                check_urlpatterns,+                cls+            )++    if django.VERSION < (4, 0):+        @classmethod+        def tearDownClass(cls):+            assert urlpatterns is cls.urlpatterns+            super().tearDownClass()+            assert urlpatterns is not cls.urlpatterns

Hrm that's interesting yeah. Looking through the commit in django/django@faba5b7 I can't see any reason why subclasses would need to stop using tearDownClass, even if Django 4.0 isn't using it directly for it's own implementation. But there's possibly some change in interaction I've not figured out there.

carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         cls._module.urlpatterns = cls.urlpatterns          cls._override.enable()++        if django.VERSION > (4, 0):+            cls.addClassCleanup(cls._override.disable)+            cls.addClassCleanup(cleanup_url_patterns, cls)

Ah fab. How about we switch based on the Python version, rather than the Django version?

carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def pytest_configure(config):         PASSWORD_HASHERS=(             'django.contrib.auth.hashers.MD5PasswordHasher',         ),+        **use_l10n,

Ah gotcha, I guess that one's probably worth a comment.

carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def test_post_form_session_auth_passing_csrf(self):         Ensure POSTing form over session authentication with CSRF token succeeds.         Regression test for #6088         """-        from django.middleware.csrf import _get_new_csrf_token+        # Remove this shim when dropping support for Django 2.2.+        if django.VERSION < (3, 0):+            from django.middleware.csrf import _get_new_csrf_token+        else:+            from django.middleware.csrf import (+                _get_new_csrf_string, _mask_cipher_secret+            )++            def _get_new_csrf_token():+                return _mask_cipher_secret(_get_new_csrf_string())

Yeah I think minimal has to be better here, too. Yes it's private API, but then it already was.

carltongibson

comment created time in a day

PullRequestReviewEvent

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         cls._module.urlpatterns = cls.urlpatterns          cls._override.enable()++        if django.VERSION > (4, 0):+            cls.addClassCleanup(cls._override.disable)+            cls.addClassCleanup(cleanup_url_patterns, cls)

Is addClassCleanup a new feature in Django 4.0?

I'm not seeing any differences in the docs re. the existing tearDownClass... https://docs.djangoproject.com/en/4.0/topics/testing/tools/#simpletestcase

carltongibson

comment created time in 2 days

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def setUpClass(cls):         super().setUpClass()         assert urlpatterns is cls.urlpatterns -    @classmethod-    def tearDownClass(cls):-        assert urlpatterns is cls.urlpatterns-        super().tearDownClass()-        assert urlpatterns is not cls.urlpatterns+        if django.VERSION > (4, 0):+            cls.addClassCleanup(+                check_urlpatterns,+                cls+            )++    if django.VERSION < (4, 0):+        @classmethod+        def tearDownClass(cls):+            assert urlpatterns is cls.urlpatterns+            super().tearDownClass()+            assert urlpatterns is not cls.urlpatterns

Same tearDownClass vs addClassCleanup question as above.

Nothing about it in the release notes... https://docs.djangoproject.com/en/4.0/releases/4.0/ so I'm curious what prompts this to need changing?

carltongibson

comment created time in a day

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def test_post_form_session_auth_passing_csrf(self):         Ensure POSTing form over session authentication with CSRF token succeeds.         Regression test for #6088         """-        from django.middleware.csrf import _get_new_csrf_token+        # Remove this shim when dropping support for Django 2.2.+        if django.VERSION < (3, 0):+            from django.middleware.csrf import _get_new_csrf_token+        else:+            from django.middleware.csrf import (+                _get_new_csrf_string, _mask_cipher_secret+            )++            def _get_new_csrf_token():+                return _mask_cipher_secret(_get_new_csrf_string())

I guess we could switch over to using the public django.middleware.csrf.get_token(request) function. (With a mocked out request instance?)

Having said that we were already relying on a bit of private implementation detail before this pull request, so this certainly isn't any worse - happy either way.

carltongibson

comment created time in 2 days

Pull request review commentencode/django-rest-framework

Django 4.0 compatibility

 def pytest_configure(config):         PASSWORD_HASHERS=(             'django.contrib.auth.hashers.MD5PasswordHasher',         ),+        **use_l10n,

Perhaps we should just keep this anyways, just to keep it simple?

        USE_L10N=True,  # This is now the default from Django 4.0 onwards.
carltongibson

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

push eventtomchristie/httpcore-the-directors-cut

Tom Christie

commit sha 6a815effbaf8563a34699518537b358c0e3fe3f7

Fix SyncByteStream/ByteStream naming

view details

push time in 2 days

push eventtomchristie/httpcore-the-directors-cut

Tom Christie

commit sha b2e6292a2f07cf8ef176705cf9153dc9fe2b0481

proxy_origin -> proxy_url

view details

push time in 2 days

push eventtomchristie/httpcore-the-directors-cut

Tom Christie

commit sha 8010435639837e1bd64bee5a600748d0a9fda75b

Add http1 argument

view details

Tom Christie

commit sha b26eec6952cb2e50aa2667d100b8a542f0107a45

Add http1 argument

view details

Tom Christie

commit sha 116756d72cb2b8e4e438e926e8fc8279a63bce4e

Support URL as a pre-parsed tuple

view details

Tom Christie

commit sha 5d3e42847d0fd30d498434ec6b593764b1f96b4e

Enable http2 flag in http/2 test case

view details

Tom Christie

commit sha 57432c5df1e50e71763396786d8ea5b55293cb70

Allow lenient types on proxy_headers argument

view details

push time in 2 days

push eventtomchristie/httpcore-the-directors-cut

Tom Christie

commit sha f3cd74084e93fdd6578fc9fa7ffdc7681998e8b1

Drop erronous module

view details

push time in 3 days

push eventtomchristie/httpcore-the-directors-cut

Tom Christie

commit sha 5816f91d536f124df3c5f282b113616179dc8942

HTTP/2 tests

view details

push time in 3 days