-
Notifications
You must be signed in to change notification settings - Fork 388
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
Linting and deprecation fixes #234
base: master
Are you sure you want to change the base?
Changes from all commits
b813fe9
2f0b3a9
3e52a9a
63d06f1
8255835
641f30b
838d5ab
320c094
849d5a0
42d4408
97ec878
9143247
c7ce7b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -50,8 +50,8 @@ def normalize_dict(dict_): | |||||||
|
||||||||
""" | ||||||||
|
||||||||
return dict([(k, v[0] if not isinstance(v, str) and len(v) == 1 else v) | ||||||||
for k, v in list(dict_.items())]) | ||||||||
return {[(k, v[0] if not isinstance(v, str) and len(v) == 1 else v) | ||||||||
for k, v in list(dict_.items())]} | ||||||||
Comment on lines
+53
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it could be rewritten like this:
Suggested change
|
||||||||
|
||||||||
|
||||||||
def items_to_dict(items): | ||||||||
|
@@ -75,7 +75,7 @@ def items_to_dict(items): | |||||||
return normalize_dict(dict(res)) | ||||||||
|
||||||||
|
||||||||
class Counter(object): | ||||||||
class Counter(): | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
""" | ||||||||
A simple counter to be used in the config to generate unique `id` values. | ||||||||
""" | ||||||||
|
@@ -181,8 +181,7 @@ def import_string(import_name, silent=False): | |||||||
if '.' in import_name: | ||||||||
module, obj = import_name.rsplit('.', 1) | ||||||||
return getattr(__import__(module, None, None, [obj]), obj) | ||||||||
else: | ||||||||
return __import__(import_name) | ||||||||
return __import__(import_name) | ||||||||
except (ImportError, AttributeError) as e: | ||||||||
if not silent: | ||||||||
raise ImportStringError('Import from string failed for path {0}' | ||||||||
|
@@ -205,8 +204,7 @@ def resolve_provider_class(class_): | |||||||
# try to import class by string from providers module or by fully | ||||||||
# qualified path | ||||||||
return import_string(class_, True) or import_string(path) | ||||||||
else: | ||||||||
return class_ | ||||||||
return class_ | ||||||||
|
||||||||
|
||||||||
def id_to_name(config, short_name): | ||||||||
|
@@ -228,7 +226,7 @@ def id_to_name(config, short_name): | |||||||
'No provider with id={0} found in the config!'.format(short_name)) | ||||||||
|
||||||||
|
||||||||
class ReprMixin(object): | ||||||||
class ReprMixin(): | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
""" | ||||||||
Provides __repr__() method with output *ClassName(arg1=value, arg2=value)*. | ||||||||
|
||||||||
|
@@ -302,7 +300,7 @@ def __init__(self, func, *args, **kwargs): | |||||||
passed to :data:`func`. | ||||||||
""" | ||||||||
|
||||||||
super(Future, self).__init__() | ||||||||
super().__init__() | ||||||||
self._func = func | ||||||||
self._args = args | ||||||||
self._kwargs = kwargs | ||||||||
|
@@ -335,7 +333,7 @@ def get_result(self, timeout=None): | |||||||
return self._result | ||||||||
|
||||||||
|
||||||||
class Session(object): | ||||||||
class Session(): | ||||||||
""" | ||||||||
A dictionary-like secure cookie session implementation. | ||||||||
""" | ||||||||
|
@@ -754,8 +752,7 @@ def expiration_date(self): | |||||||
|
||||||||
if self.expire_in < 0: | ||||||||
return None | ||||||||
else: | ||||||||
return datetime.datetime.fromtimestamp(self.expiration_time) | ||||||||
return datetime.datetime.fromtimestamp(self.expiration_time) | ||||||||
|
||||||||
@property | ||||||||
def valid(self): | ||||||||
|
@@ -765,8 +762,7 @@ def valid(self): | |||||||
|
||||||||
if self.expiration_time: | ||||||||
return self.expiration_time > int(time.time()) | ||||||||
else: | ||||||||
return True | ||||||||
return True | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even simpler: return self.expiration_time and self.expiration_time > int(time.time()) |
||||||||
|
||||||||
def expire_soon(self, seconds): | ||||||||
""" | ||||||||
|
@@ -783,8 +779,7 @@ def expire_soon(self, seconds): | |||||||
|
||||||||
if self.expiration_time: | ||||||||
return self.expiration_time < int(time.time()) + int(seconds) | ||||||||
else: | ||||||||
return False | ||||||||
return False | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: return self.expiration_time and self.expiration_time < int(time.time()) + int(seconds) |
||||||||
|
||||||||
def refresh(self, force=False, soon=86400): | ||||||||
""" | ||||||||
|
@@ -1066,7 +1061,7 @@ def user(self): | |||||||
return self.provider.user if self.provider else None | ||||||||
|
||||||||
def to_dict(self): | ||||||||
return dict(provider=self.provider, user=self.user, error=self.error) | ||||||||
return {'provider': self.provider, 'user': self.user, 'error': self.error} | ||||||||
|
||||||||
def to_json(self, indent=4): | ||||||||
return json.dumps(self, default=lambda obj: obj.to_dict( | ||||||||
|
@@ -1180,7 +1175,7 @@ class UserInfoResponse(Response): | |||||||
""" | ||||||||
|
||||||||
def __init__(self, user, *args, **kwargs): | ||||||||
super(UserInfoResponse, self).__init__(*args, **kwargs) | ||||||||
super().__init__(*args, **kwargs) | ||||||||
|
||||||||
#: :class:`.User` instance. | ||||||||
self.user = user | ||||||||
|
@@ -1254,14 +1249,16 @@ def full_url(self): | |||||||
return self.url + '?' + self.query_string | ||||||||
|
||||||||
def to_json(self): | ||||||||
return json.dumps(dict(url=self.url, | ||||||||
method=self.method, | ||||||||
params=self.params, | ||||||||
headers=self.headers, | ||||||||
body=self.body)) | ||||||||
return json.dumps({ | ||||||||
'url': self.url, | ||||||||
'method': self.method, | ||||||||
'params': self.params, | ||||||||
'headers': self.headers, | ||||||||
'body': self.body | ||||||||
}) | ||||||||
|
||||||||
|
||||||||
class Authomatic(object): | ||||||||
class Authomatic(): | ||||||||
def __init__( | ||||||||
self, config, secret, session_max_age=600, secure_cookie=False, | ||||||||
session=None, session_save_method=None, report_errors=True, | ||||||||
|
@@ -1373,10 +1370,7 @@ def login(self, adapter, provider_name, callback=None, | |||||||
raise ConfigError('Provider name "{0}" not specified!' | ||||||||
.format(provider_name)) | ||||||||
|
||||||||
if not (session is None or session_saver is None): | ||||||||
session = session | ||||||||
session_saver = session_saver | ||||||||
else: | ||||||||
if session is None or session_saver is None: | ||||||||
session = Session(adapter=adapter, | ||||||||
secret=self.secret, | ||||||||
max_age=self.session_max_age, | ||||||||
|
@@ -1408,9 +1402,8 @@ def login(self, adapter, provider_name, callback=None, | |||||||
# return login result | ||||||||
return provider.login() | ||||||||
|
||||||||
else: | ||||||||
# Act like backend. | ||||||||
self.backend(adapter) | ||||||||
# Act like backend. | ||||||||
self.backend(adapter) | ||||||||
|
||||||||
def credentials(self, credentials): | ||||||||
""" | ||||||||
|
@@ -1600,9 +1593,7 @@ def request_elements( | |||||||
|
||||||||
if return_json: | ||||||||
return request_elements.to_json() | ||||||||
|
||||||||
else: | ||||||||
return request_elements | ||||||||
return request_elements | ||||||||
|
||||||||
def backend(self, adapter): | ||||||||
""" | ||||||||
|
@@ -1714,7 +1705,7 @@ def get(self): | |||||||
jsonp = params.get('callback') | ||||||||
|
||||||||
# JSONP is possible only with GET method. | ||||||||
if ProviderClass.supports_jsonp and method is 'GET': | ||||||||
if ProviderClass.supports_jsonp and method == 'GET': | ||||||||
request_type = 'elements' | ||||||||
else: | ||||||||
# Remove the JSONP callback | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.