Skip to content

Commit

Permalink
Fixing broken library for python 2 because of open() encoding kwarg (
Browse files Browse the repository at this point in the history
…#34)

* Fixed `open()` function in `setup.py` that broke on python 2.7.3 because of `encoding` keyword argument. The fix calls `io` native library that ensures backward compatibility for the `open()` built-in function. 
* Removed useless `requirements.txt` that caused the dependency bot to raise security alerts (because of some known vulnerabilities on django 3.0.X)
  • Loading branch information
alaouimehdi1995 authored Apr 20, 2021
1 parent 04c2cd9 commit 6898041
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion django_rest/deserializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Deserializer(six.with_metaclass(DeclarativeFieldsMetaclass, BaseDeserializ


class AllPassDeserializer(Deserializer):
""" Deserializer that accepts any given data. the clean always returns
"""Deserializer that accepts any given data. the clean always returns
the data received as input.
"""

Expand Down
14 changes: 7 additions & 7 deletions django_rest/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class MetaOperand(type):
""" Metaclass that allows its instances (permission classes) to use logical
"""Metaclass that allows its instances (permission classes) to use logical
using logical operators (AND, OR, ..) with the follwing syntax:
FinalPermClass = (Perm1 | Perm2) & ~Perm3
Expand Down Expand Up @@ -43,7 +43,7 @@ def __invert__(first_class):


class BinaryOperator(object):
""" Class that describes how to build a permission class as a result of a
"""Class that describes how to build a permission class as a result of a
Binary operators only. The current class is intended to be inherited by operators
like: `AND`, `OR`, `XOR`, etc.
Expand Down Expand Up @@ -108,7 +108,7 @@ def has_permission(self, request, view):


class UnaryOperator(object):
""" Class that describes how to build a permission class as a result of a
"""Class that describes how to build a permission class as a result of a
Unary operators only. The current class is intended to be inherited by operators
like: `NOT` and Identity operators.
Expand Down Expand Up @@ -168,7 +168,7 @@ def has_permission(self, request, view):


class AND(six.with_metaclass(MetaOperand, BinaryOperator)):
""" AND Logical operator class.
"""AND Logical operator class.
Example of use:
Expand All @@ -186,7 +186,7 @@ def calculate(first_function, second_function, *args, **kwargs):


class OR(six.with_metaclass(MetaOperand, BinaryOperator)):
""" OR Logical operator class.
"""OR Logical operator class.
Example of use:
Expand All @@ -204,7 +204,7 @@ def calculate(first_function, second_function, *args, **kwargs):


class XOR(six.with_metaclass(MetaOperand, BinaryOperator)):
""" XOR (eXclusive OR) Logical operator class.
"""XOR (eXclusive OR) Logical operator class.
Example of use:
Expand All @@ -222,7 +222,7 @@ def calculate(first_function, second_function, *args, **kwargs):


class NOT(six.with_metaclass(MetaOperand, UnaryOperator)):
""" NOT Logical operator class.
"""NOT Logical operator class.
Example of use:
Expand Down
6 changes: 3 additions & 3 deletions django_rest/serializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Field(object):
""" The Field class is used to define what attributes will be serialized.
"""The Field class is used to define what attributes will be serialized.
It maps a property or function on an object to a value in the serialized result.
Subclass this to make custom fields. For most simple cases, overriding
Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, attr_name=None, call=False, label=None, required=True):

def to_value(self, value):
# type:(Any) -> Any
""" Transforms the serialized value. It could be used for cleaning
"""Transforms the serialized value. It could be used for cleaning
and validating the value serialized by the current field. For example,
to implement an `int` field, the Field.to_value() method will looks like:
Expand All @@ -60,7 +60,7 @@ def _is_to_value_overridden(self):

def as_getter(self, serializer_field_name, serializer_cls):
# type:(str, type) -> Optional[Callable]
""" Returns a function that fetches an attribute from an object.
"""Returns a function that fetches an attribute from an object.
If `None` is returned, the default getter defined in `Serializer.default_getter`
will be used instead.
Expand Down
4 changes: 2 additions & 2 deletions django_rest/serializers/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _is_valid_field_instance(field_instance):

def ListField(field_instance):
# type:(Field) -> Field
""" Allows to apply the Field.to_value() method on an iterable of values,
"""Allows to apply the Field.to_value() method on an iterable of values,
instead of a single value. The same purpose could be achieved with `MethodField()`,
but it'll be just too annoying.
Example:
Expand Down Expand Up @@ -190,7 +190,7 @@ def _is_primitive_const(cls, constant):


class MethodField(Field):
""" A Field class that calls a method on the `Serializer` class.
"""A Field class that calls a method on the `Serializer` class.
This is useful if a Field needs to serialize a value that may come from multiple
attributes on the same object. For example:
Expand Down
6 changes: 3 additions & 3 deletions django_rest/serializers/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __new__(cls, name, bases, attrs):


class Serializer(six.with_metaclass(SerializerMeta, SerializerBase)):
""" The Serializer class is used as a base for custom serializers.
"""The Serializer class is used as a base for custom serializers.
A Serializer class is also a subclass of Field class, which allows nesting
Serializers. A new serializer is defined by subclassing the `Serializer` class,
Expand Down Expand Up @@ -134,7 +134,7 @@ def to_value(self, instance):
@property
def data(self):
# type:() -> Dict[str, Any]
""" Get the serialized data from the Serializer instance. The data is cached
"""Get the serialized data from the Serializer instance. The data is cached
for further accesses.
"""
# Cache the data for next time `.data` is called.
Expand All @@ -144,7 +144,7 @@ def data(self):


class DictSerializer(Serializer):
""" DictSerializer serializes python `dicts` instead of objects.
"""DictSerializer serializes python `dicts` instead of objects.
`DictSerializer` uses `operator.itemgetter` to fetch data from the object
to serialize, while `Serializer` class uses `operator.attrgetter`.
Expand Down
11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from io import open
from setuptools import find_packages, setup

with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()

setup(
name="django-rest",
version="0.8.6",
version="0.8.7",
url="https://github.com/alaouimehdi1995/django-rest/",
license="MIT",
description="Tiny, lightweight, blazing fast REST library for django",
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ django==2.*; python_version >= '3' and python_version < '3.6'
django==3.*; python_version >= '3.6'
enum34; python_version < '3'
flake8
mock; python_version < '3'
mock
pudb
pytest
pytest-cov
Expand Down

0 comments on commit 6898041

Please sign in to comment.