Skip to content

clean python 2 codes #976

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

Merged
merged 17 commits into from
Oct 20, 2021
Merged

clean python 2 codes #976

merged 17 commits into from
Oct 20, 2021

Conversation

auvipy
Copy link
Contributor

@auvipy auvipy commented Sep 13, 2021

Description of the Change

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@codecov
Copy link

codecov bot commented Sep 13, 2021

Codecov Report

Merging #976 (cc6cd01) into master (c763b97) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #976      +/-   ##
==========================================
- Coverage   96.84%   96.84%   -0.01%     
==========================================
  Files          65       65              
  Lines        3933     3925       -8     
==========================================
- Hits         3809     3801       -8     
  Misses        124      124              
Impacted Files Coverage Δ
example/factories.py 100.00% <ø> (ø)
example/migrations/0001_initial.py 100.00% <ø> (ø)
example/migrations/0002_taggeditem.py 100.00% <ø> (ø)
example/migrations/0003_polymorphics.py 100.00% <ø> (ø)
example/migrations/0004_auto_20171011_0631.py 100.00% <ø> (ø)
example/models.py 100.00% <ø> (ø)
example/tests/snapshots/snap_test_errors.py 100.00% <ø> (ø)
example/tests/snapshots/snap_test_openapi.py 100.00% <ø> (ø)
example/tests/unit/test_serializer_method_field.py 100.00% <ø> (ø)
example/api/resources/identity.py 100.00% <100.00%> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c763b97...cc6cd01. Read the comment docs.

@auvipy
Copy link
Contributor Author

auvipy commented Sep 13, 2021

@sliverc

@sliverc
Copy link
Member

sliverc commented Sep 13, 2021

@auvipy Thanks for this other cleanup up. As this is the second of these PRs do you think you caught all the Python 2 left over now? Maybe good to quickly go through all the code. I just want to avoid plenty of the same kind of commits if at all possible.

@auvipy
Copy link
Contributor Author

auvipy commented Sep 14, 2021

possible

@sliverc
Copy link
Member

sliverc commented Sep 14, 2021

A couple of greps reveals that there a few more occurrences to clean up (I have run those on master):

$ git grep "super(" | grep -v "super()"
docs/usage.md:        queryset = super(LineItemViewSet, self).get_queryset()
example/api/resources/identity.py:        return super(Identity, self).retrieve(request, args, kwargs)
example/serializers.py:        super(EntrySerializer, self).__init__(*args, **kwargs)
example/serializers.py:        obj = super(CurrentProjectRelatedField, self).get_attribute(instance)
example/tests/__init__.py:        super(TestBase, self).setUp()
example/tests/test_format_keys.py:        super(FormatKeysSetTests, self).setUp()
example/tests/test_generic_validation.py:        super(GenericValidationTest, self).setUp()
example/tests/test_model_viewsets.py:        super(ModelViewSetTests, self).setUp()
example/tests/test_serializers.py:            return super(ArtProjectSerializer, child_self).__init__(
example/tests/unit/test_filter_schema_params.py:        super(DummyEntryViewSet, self).__init__(**kwargs)
example/tests/unit/test_renderer_class_methods.py:            return super(CustomRenderer, cls).extract_attributes(fields, resource)
example/tests/unit/test_renderer_class_methods.py:            return super(CustomRenderer, cls).extract_relationships(
example/views.py:        return super(BlogViewSet, self).get_object()
example/views.py:        return super(DRFBlogViewSet, self).get_object()
example/views.py:        response = super(JsonApiViewSet, self).handle_exception(exc)
example/views.py:        return super(EntryViewSet, self).get_object()
example/views.py:        return super(DRFEntryViewSet, self).get_object()
example/views.py:        return super(CommentViewSet, self).get_queryset()
rest_framework_json_api/django_filters/backends.py:        result = super(DjangoFilterBackend, self).get_schema_operation_parameters(view)
rest_framework_json_api/filters.py:        return super(OrderingFilter, self).remove_invalid_fields(
rest_framework_json_api/parsers.py:        result = super(JSONParser, self).parse(
rest_framework_json_api/relations.py:        return super(ResourceRelatedField, self).to_internal_value(data["id"])
rest_framework_json_api/renderers.py:        context = super(BrowsableAPIRenderer, self).get_context(
rest_framework_json_api/serializers.py:        fields = super(ModelSerializer, self).get_field_names(declared, info)
$ git grep "(object)"
example/tests/test_serializers.py:class TestModelSerializer(object):
$ git grep "coding: utf-8"
docs/conf.py:# -*- coding: utf-8 -*-
example/factories.py:# -*- encoding: utf-8 -*-
example/migrations/0001_initial.py:# -*- coding: utf-8 -*-
example/migrations/0002_taggeditem.py:# -*- coding: utf-8 -*-
example/migrations/0003_polymorphics.py:# -*- coding: utf-8 -*-
example/migrations/0004_auto_20171011_0631.py:# -*- coding: utf-8 -*-
example/models.py:# -*- encoding: utf-8 -*-
example/tests/snapshots/snap_test_errors.py:# -*- coding: utf-8 -*-
example/tests/snapshots/snap_test_openapi.py:# -*- coding: utf-8 -*-
rest_framework_json_api/__init__.py:# -*- coding: utf-8 -*-

@auvipy
Copy link
Contributor Author

auvipy commented Sep 28, 2021

ok I will revisit this soon

@auvipy
Copy link
Contributor Author

auvipy commented Oct 17, 2021

i might make some mistake

@sliverc
Copy link
Member

sliverc commented Oct 18, 2021

@auvipy I will look at the code changes in more detail later, but it seems CI is failing. Could you have a look why this could be? Thanks.

@auvipy
Copy link
Contributor Author

auvipy commented Oct 19, 2021

thats why i prefer smaller chuncks at a time. im not sure why command failed

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. See inline comment in terms of the failing test.

Following occurrences have been missed:

example/tests/test_serializers.py:            return super(ArtProjectSerializer, child_self).__init__(
example/tests/unit/test_filter_schema_params.py:        super(DummyEntryViewSet, self).__init__(**kwargs)
example/tests/unit/test_renderer_class_methods.py:            return super(CustomRenderer, cls).extract_attributes(fields, resource)
example/tests/unit/test_renderer_class_methods.py:            return super(CustomRenderer, cls).extract_relationships(
example/tests/unit/test_serializer_method_field.py:from __future__ import absolute_import

Once this are fixed this PR should be ready for merging.

@auvipy
Copy link
Contributor Author

auvipy commented Oct 20, 2021

i dont thin we can remove this class TestPolymorphicModelSerializer(TestCase):
def setUp(self):
self.project = ArtProjectFactory.create()
self.child_init_args = {}

    # Override `__init__` with our own method
    def overridden_init(child_self, instance=None, data=empty, **kwargs):
        """
        Override `ArtProjectSerializer.__init__` with the same signature that
        `BaseSerializer.__init__` has to assert that it receives the parameters
        that `BaseSerializer` expects
        """
        self.child_init_args = dict(instance=instance, data=data, **kwargs)

        return super(ArtProjectSerializer, child_self).__init__(
            instance, data, **kwargs
        )

@auvipy auvipy closed this Oct 20, 2021
@auvipy auvipy reopened this Oct 20, 2021
@auvipy
Copy link
Contributor Author

auvipy commented Oct 20, 2021

all green

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me now.

@sliverc sliverc merged commit c4337f1 into django-json-api:master Oct 20, 2021
@auvipy
Copy link
Contributor Author

auvipy commented Oct 21, 2021

yea! thanks a lot for guiding!

@auvipy auvipy deleted the py2cln branch October 21, 2021 06:52
@sliverc sliverc mentioned this pull request Oct 22, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants