From 9e7ea29f5e9f7155c90c26cdc524b8a2c6f80fe2 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 23 Jul 2018 12:20:12 +0200 Subject: [PATCH] [Lint] Make PyLint happy again --- calsocial/cache.py | 16 +++++++++++----- calsocial/calendar_system/gregorian.py | 2 +- calsocial/utils.py | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/calsocial/cache.py b/calsocial/cache.py index 5628662..b261e39 100644 --- a/calsocial/cache.py +++ b/calsocial/cache.py @@ -21,7 +21,7 @@ from datetime import timedelta import pickle from uuid import uuid4 -from flask import current_app, has_request_context, request, session +from flask import has_request_context, request as flask_request, session as flask_session from flask.sessions import SessionInterface, SessionMixin from flask_caching import Cache from werkzeug.datastructures import CallbackDict @@ -46,7 +46,7 @@ class CachedSession(CallbackDict, SessionMixin): # pylint: disable=too-many-anc self.__modifying = True if has_request_context(): - self['ip'] = request.remote_addr + self['ip'] = flask_request.remote_addr self.modified = True @@ -59,6 +59,9 @@ class CachedSession(CallbackDict, SessionMixin): # pylint: disable=too-many-anc @property def user(self): + """The user this session belongs to + """ + from calsocial.models import User if 'user_id' not in self: @@ -87,11 +90,11 @@ class CachedSessionInterface(SessionInterface): return str(uuid4()) @staticmethod - def get_cache_expiration_time(app, session): + def get_cache_expiration_time(app, sess): """Get the expiration time of the cache entry """ - if session.permanent: + if sess.permanent: return app.permanent_session_lifetime return timedelta(days=1) @@ -147,7 +150,10 @@ class CachedSessionInterface(SessionInterface): domain=domain) def delete_session(self, sid): - if has_request_context() and session.sid == sid: + """Delete the session with ``sid`` as its session ID + """ + + if has_request_context() and flask_session.sid == sid: raise ValueError('Will not delete the current session') cache.delete(self.prefix + sid) diff --git a/calsocial/calendar_system/gregorian.py b/calsocial/calendar_system/gregorian.py index 7afb0b6..8c76236 100644 --- a/calsocial/calendar_system/gregorian.py +++ b/calsocial/calendar_system/gregorian.py @@ -219,7 +219,7 @@ class GregorianCalendar(CalendarSystem): end_timestamp = start_timestamp + timedelta(days=1) events = events.filter((Event.start_time <= end_timestamp) & - (Event.end_time >= start_timestamp)) \ + (Event.end_time >= start_timestamp)) \ .order_by('start_time', 'end_time') if user is None: diff --git a/calsocial/utils.py b/calsocial/utils.py index 09b22af..036657e 100644 --- a/calsocial/utils.py +++ b/calsocial/utils.py @@ -89,6 +89,9 @@ class RoutedMixin: """ def register_routes(self): + """Register all routes that were marked with :meth:`route` + """ + for attr_name in self.__dir__(): attr = getattr(self, attr_name)