Skip to content

Commit

Permalink
drop python 2.7 support (fixes #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Aug 3, 2022
1 parent 5ed4e90 commit d8c187f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
12 changes: 2 additions & 10 deletions rest_pandas/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@
from rest_framework import status
from tempfile import mkstemp
from pandas import DataFrame

try:
# Python 2 (uses str)
from StringIO import StringIO
except ImportError:
# Python 3 (Python 2 equivalent uses unicode)
from io import StringIO

from io import StringIO, BytesIO
import os
from io import BytesIO


RESPONSE_ERROR = (
Expand Down Expand Up @@ -189,7 +181,7 @@ def render_dataframe(self, data, name, *args, **kwargs):
if kwargs.get('orient') == 'records-index':
kwargs['orient'] = 'records'
data.reset_index(inplace=True)
return super(PandasJSONRenderer, self).render_dataframe(
return super().render_dataframe(
data, name, *args, **kwargs
)

Expand Down
4 changes: 2 additions & 2 deletions rest_pandas/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def transform_dataframe(self, dataframe):

@property
def data(self):
data = super(serializers.ListSerializer, self).data
data = super().data
if isinstance(data, DataFrame) or data:
dataframe = self.get_dataframe(data)
return self.transform_dataframe(dataframe)
Expand All @@ -53,7 +53,7 @@ def data(self):
def to_representation(self, data):
if isinstance(data, DataFrame):
return data
return super(PandasSerializer, self).to_representation(data)
return super().to_representation(data)

@property
def model_serializer(self):
Expand Down
4 changes: 2 additions & 2 deletions rest_pandas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class PandasView(PandasViewBase, ListAPIView):
"""

def list(self, request, *args, **kwargs):
response = super(PandasView, self).list(request, *args, **kwargs)
response = super().list(request, *args, **kwargs)
return self.update_pandas_headers(response)


Expand All @@ -135,5 +135,5 @@ class PandasViewSet(PandasViewBase, ListModelMixin, GenericViewSet):
Pandas-capable model ViewSet (list only)
"""
def list(self, request, *args, **kwargs):
response = super(PandasViewSet, self).list(request, *args, **kwargs)
response = super().list(request, *args, **kwargs)
return self.update_pandas_headers(response)

0 comments on commit d8c187f

Please sign in to comment.