diff --git a/README.md b/README.md index f5e8abf..a8eb96b 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ DYSESSION = { | DYNAMODB_REGION | ap-northeast-1 | The region of the DynamoDB table | | LOGGING | Dict | Configuration of Logging | | LOGGING["TYPE"] | CONSOLE | Only accept two kinds of parameters: `CONSOLE`, `FILE`. If this set to `CONSOLE`, django-dysession will use `StreamHandler` to stream to the console. If this set to `FILE`, django-dysession will use `FileHandler` to stream to `LOGGING["FILE_PATH"]`. | -| LOGGING["FILE_PATH"] | session.log | The file path to save logs of session managements. | +| LOGGING["FILE_PATH"] | session.log | Optional. Only use this configuration when LOGGING["TYPE"] is set to `FILE`. The file path to save logs of session managements. | ## Logging diff --git a/dysession/backends/db.py b/dysession/backends/db.py index 8a57f46..6860b3a 100644 --- a/dysession/backends/db.py +++ b/dysession/backends/db.py @@ -58,7 +58,7 @@ def _get_session(self, no_load=False) -> SessionDataModel: def key_salt(self): return "dysession.backends." + self.__class__.__qualname__ - def is_empty(self): + def is_empty(self) -> bool: "Return True when there is no session_key and the session is empty." try: return not self._session_key and not self._session_cache.is_empty @@ -69,10 +69,10 @@ def clear(self): super().clear() self._session_cache = SessionDataModel() - def items(self): + def items(self) -> Dict[str, Any]: return self._session.items() - def __str__(self): + def __str__(self) -> str: return str(self._get_session()) # Methods that subclass must implement @@ -124,7 +124,6 @@ def delete(self, session_key=None): if session_key is None: session_key = self._session_key - try: self.db.delete(self._get_session()) except DeleteSessionError: diff --git a/dysession/backends/model.py b/dysession/backends/model.py index 261ca6f..a3a1309 100644 --- a/dysession/backends/model.py +++ b/dysession/backends/model.py @@ -48,12 +48,12 @@ def __delitem__(self, key): def __iter__(self): return iter(self.__variables_names) - def __is_empty(self): + def __is_empty(self) -> bool: return len(self.__variables_names) == 0 is_empty = property(__is_empty) - def get(self, key, default=...): + def get(self, key, default=...) -> Any: try: return self[key] except AttributeError: @@ -61,7 +61,7 @@ def get(self, key, default=...): raise return default - def pop(self, key, default=...): + def pop(self, key, default=...) -> Any: try: ret = self[key] del self[key] diff --git a/dysession/logger/__init__.py b/dysession/logger/__init__.py index 334b77c..60863c6 100644 --- a/dysession/logger/__init__.py +++ b/dysession/logger/__init__.py @@ -10,6 +10,7 @@ class LoggingType(Enum): + """Enum of python logger type.""" PLAINTEXT_CONSOLE = auto() COLOR_CONSOLE = auto() diff --git a/dysession/logger/handler/colorful_console.py b/dysession/logger/handler/colorful_console.py index 1139523..298e981 100644 --- a/dysession/logger/handler/colorful_console.py +++ b/dysession/logger/handler/colorful_console.py @@ -1,8 +1,9 @@ import logging +from typing import Dict from .ansi import ANSIColor -LOGLEVEL_TRANSFORM = { +LOGLEVEL_TRANSFORM: Dict[int, str] = { logging.DEBUG: ANSIColor.DEBUG.value, logging.INFO: ANSIColor.OKCYAN.value, logging.WARNING: ANSIColor.WARNING.value, diff --git a/dysession/settings.py b/dysession/settings.py index d255252..4dcbb7e 100644 --- a/dysession/settings.py +++ b/dysession/settings.py @@ -29,6 +29,9 @@ def get_config() -> Dict[str, Union[str, int]]: * TTL_ATTRIBUTE_NAME * CACHE_PERIOD * DYNAMODB_REGION + * LOGGING + * TYPE + * FILE_PATH Returns: Dict[str, Union[str, int]] diff --git a/dysession/version.txt b/dysession/version.txt index 1cc5f65..8cfbc90 100644 --- a/dysession/version.txt +++ b/dysession/version.txt @@ -1 +1 @@ -1.1.0 \ No newline at end of file +1.1.1 \ No newline at end of file