GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — v1 ( b4dcfa...110339 )
by Maksim
01:36
created

_set()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 7
rs 9.4285
ccs 6
cts 6
cp 1
crap 1
1
# -*- coding: utf-8 -*-
2
3 1
import pydash
4
5
6 1
def _handle_auto_doc_for_property(doc, typename):
7 1
	if doc is None:
8
		doc = '<AUTO>'
9
10 1
	if '<AUTO>' in doc:
11 1
		subst = (
12
			':getter: Get\n'
13
			'{pref}:setter: Set\n'
14
			'{pref}:rtype: {typename}'
15
		).format(
16
			typename=typename,
17
			pref='\t\t',
18
		)
19 1
		doc = doc.replace('<AUTO>', subst)
20
21 1
	return doc
22
23
24 1
def dict_enum_property(path, enumtype):
25 1
	def decorator(fn):
26
27 1
		def _get(self):
28 1
			v = pydash.get(self.raw, path)
29
30 1
			if v is None:
31
				return None
32
33 1
			return enumtype(v)
34
35 1
		def _set(self, value):
36 1
			if isinstance(value, enumtype):
37 1
				value = value.value
38 1
			value = fn(self, value)
39 1
			pydash.set_(self.raw, path, value)
40
41 1
			return enumtype(value)
42
43 1
		doc = _handle_auto_doc_for_property(
44
			fn.__doc__,
45
			'~{mod}.{nm}'.format(
46
				mod=enumtype.__module__,
47
				nm=enumtype.__name__,
48
			)
49
		)
50
51 1
		p = property(_get, _set, None, doc)
52 1
		return p
53 1
	return decorator
54
55
56
# TODO: test over unicode in python 2
57 1
def dict_property(path, anytype):
58
	"""
59
	Creates new strict-typed PROPERTY for classes inherited from :class:`dict`
60
	"""
61 1
	def decorator(fn):
62
63 1
		def _get(self):
64 1
			v = pydash.get(self.raw, path)
65
66 1
			if v is None:
67 1
				return None
68
69 1
			return anytype(v)
70
71 1
		def _set(self, value):
72
			value = fn(self, value)
73
			pydash.set_(self.raw, path, value)
74
75
			return value
76
77 1
		doc = fn.__doc__
78
79 1
		if doc is None:
80
			doc = '<AUTO>'
81
82 1
		doc = _handle_auto_doc_for_property(
83
			fn.__doc__,
84
			anytype.__name__
85
		)
86
87 1
		p = property(_get, _set, None, doc)
88 1
		return p
89
	return decorator
90