Passed
Pull Request — master (#244)
by Piotr
01:02
created

ProviderAuthSerializer.create()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
1
from rest_framework import serializers
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Unable to import 'rest_framework'
Loading history...
2
3
from social_core import exceptions
0 ignored issues
show
introduced by
Unable to import 'social_core'
Loading history...
4
from social_django.utils import load_backend, load_strategy
0 ignored issues
show
introduced by
Unable to import 'social_django.utils'
Loading history...
5
6
7
class ProviderAuthSerializer(serializers.Serializer):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
8
    id = serializers.IntegerField(read_only=True)
0 ignored issues
show
Coding Style Naming introduced by
The name id does not conform to the class attribute naming conventions (([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
9
    email = serializers.CharField(read_only=True)
10
    code = serializers.CharField(write_only=True)
11
    state = serializers.CharField(required=False, write_only=True)
12
13
    def create(self, validated_data):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument validated_data seems to be unused.
Loading history...
14
        strategy = load_strategy(self.context['request'])
15
        redirect_uri = strategy.session_get('redirect_uri')
16
17
        backend_name = self.context['view'].kwargs['provider']
18
        backend = load_backend(
19
            strategy, backend_name, redirect_uri=redirect_uri
20
        )
21
        return backend.auth_complete()
22
23
    def update(self, instance, validated_data):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
24
        pass
25
26
    def validate_state(self, value):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument value seems to be unused.
Loading history...
27
        strategy = load_strategy(self.context['request'])
28
        redirect_uri = strategy.session_get('redirect_uri')
29
30
        backend_name = self.context['view'].kwargs['provider']
31
        backend = load_backend(
32
            strategy, backend_name, redirect_uri=redirect_uri
33
        )
34
35
        try:
36
            backend.validate_state()
37
        except exceptions.AuthException:
38
            raise serializers.ValidationError('State could not be verified.')
39