diff --git a/minio_storage/files.py b/minio_storage/files.py index 880aa67..317ed13 100644 --- a/minio_storage/files.py +++ b/minio_storage/files.py @@ -64,7 +64,8 @@ def __init__( self.max_memory_size = max_memory_size super().__init__(name, mode, storage) - def _get_file(self): + @property + def file(self): if self._file is None: try: obj = self._storage.client.get_object( @@ -82,11 +83,10 @@ def _get_file(self): logger.error(str(e)) return self._file + @file.setter def _set_file(self, value): self._file = value - file = property(_get_file, _set_file) - def close(self): try: self.file.close() @@ -116,7 +116,8 @@ def __init__( self.max_memory_size = max_memory_size super().__init__(name, mode, storage) - def _get_file(self): + @property + def file(self): if self._file is None: try: obj = self._storage.client.get_object( @@ -138,11 +139,10 @@ def _get_file(self): logger.error(str(e)) return self._file + @file.setter def _set_file(self, value): self._file = value - file = property(_get_file, _set_file) - def close(self): if self._file is not None: self._file.close() diff --git a/minio_storage/management/commands/minio.py b/minio_storage/management/commands/minio.py index feba4f9..85673c2 100644 --- a/minio_storage/management/commands/minio.py +++ b/minio_storage/management/commands/minio.py @@ -1,6 +1,7 @@ import argparse import json import sys +import typing as T from string import Template from unittest.mock import patch @@ -162,7 +163,7 @@ def bucket_list( list_dirs: bool, list_files: bool, recursive: bool, - format: str = None, + format: T.Optional[str] = None, summary: bool = True, ): try: diff --git a/pyrightconfig.json b/pyrightconfig.json index 6e0e64f..588000c 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -8,11 +8,11 @@ ], "reportMissingImports": true, "reportMissingTypeStubs": false, - "strictParameterNoneValue": false, - "reportInvalidStringEscapeSequence": "warning", - "reportUnboundVariable": "warning", - "reportOptionalMemberAccess": "warning", - "reportOptionalIterable": "warning", + "strictParameterNoneValue": true, + "reportInvalidStringEscapeSequence": "error", + "reportUnboundVariable": "error", + "reportOptionalMemberAccess": "error", + "reportOptionalIterable": "error", "pythonVersion": "3.8", "pythonPlatform": "Linux" } diff --git a/tox.ini b/tox.ini index b45cce3..8792aae 100644 --- a/tox.ini +++ b/tox.ini @@ -52,6 +52,7 @@ depends=py311-django42-minioknown basepython = python3 deps = pyright + django-stubs==4.2.0 -rdev-requirements.txt commands = pyright --skipunannotated --level WARNING