Skip to content

Commit

Permalink
add stricter type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasf committed May 5, 2023
1 parent 76a51d0 commit ade7d81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions minio_storage/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down Expand Up @@ -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(
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion minio_storage/management/commands/minio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import json
import sys
import typing as T
from string import Template
from unittest.mock import patch

Expand Down Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ade7d81

Please sign in to comment.