Skip to content

Commit

Permalink
Bump pylint from 2.8.3 to 2.11.1 (#226)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
  • Loading branch information
dependabot[bot] and MartinHjelmare committed Sep 20, 2021
1 parent e02a22c commit 80ff1e5
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions imjoy_elfinder/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def main(args: Optional[List[str]] = None) -> None:
if opt.base_url and opt.base_url.startswith("http"):
url = opt.base_url
else:
url = "http://{}:{}".format(opt.host, opt.port)
url = f"http://{opt.host}:{opt.port}"

print("==========ImJoy elFinder server is running=========\n{}\n".format(url))
print(f"==========ImJoy elFinder server is running=========\n{url}\n")

sys.stdout.flush()

Expand Down
26 changes: 14 additions & 12 deletions imjoy_elfinder/elfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,14 @@ def exception_to_string(excp: Exception) -> str:
excp.__traceback__
) # add limit=??
pretty = traceback.format_list(stack)
return "".join(pretty) + "\n {} {}".format(excp.__class__, excp)
return "".join(pretty) + f"\n {excp.__class__} {excp}"


class Connector:
"""Connector for elFinder."""

# pylint: disable=too-many-instance-attributes, too-many-arguments
# pylint: disable=unused-private-member

# The options need to be persistent between connector instances.
_options = {
Expand Down Expand Up @@ -383,15 +384,13 @@ def run(
try:
func()
except Exception as exc: # pylint: disable=broad-except
self._response[R_ERROR] = "Command Failed: {}, Error: \n{}".format(
self._request[API_CMD], exc
)
self._response[
R_ERROR
] = f"Command Failed: {self._request[API_CMD]}, Error: \n{exc}"
traceback.print_exc()
self._debug("exception", exception_to_string(exc))
else:
self._response[R_ERROR] = "Unknown command: {}".format(
self._request[API_CMD]
)
self._response[R_ERROR] = f"Unknown command: {self._request[API_CMD]}"

if self._error_data:
self._debug("errorData", self._error_data)
Expand Down Expand Up @@ -716,10 +715,12 @@ def __mkfile(self) -> None:
self._response[R_ERROR] = "File or folder with the same name already exists"
else:
try:
open(new_file, "w").close()
self._response[R_ADDED] = [self._info(new_file)]
with open(new_file, "w", encoding="utf-8"):
pass
except OSError:
self._response[R_ERROR] = "Unable to create file"
else:
self._response[R_ADDED] = [self._info(new_file)]

def __rm(self) -> None:
"""Delete files and directories."""
Expand Down Expand Up @@ -841,6 +842,7 @@ def __upload_large_file(self) -> None:
with open(
record_path,
"r+" if os.path.exists(record_path) else "w+",
encoding="utf-8",
) as record_fil:
record_fil.seek(chunk_index)
record_fil.write("X")
Expand Down Expand Up @@ -1279,7 +1281,7 @@ def __get(self) -> None:
return

try:
with open(cur_file, "r") as text_fil:
with open(cur_file, "r", encoding="utf-8") as text_fil:
self._response[API_CONTENT] = text_fil.read()
except UnicodeDecodeError:
with open(cur_file, "rb") as bin_fil:
Expand Down Expand Up @@ -1338,7 +1340,7 @@ def __put(self) -> None:
with open(cur_file, "wb") as bin_fil:
bin_fil.write(img_data)
else:
with open(cur_file, "w+") as text_fil:
with open(cur_file, "w+", encoding="utf-8") as text_fil:
text_fil.write(self._request[API_CONTENT])
self._rm_tmb(cur_file)
self._response[R_CHANGED] = [self._info(cur_file)]
Expand Down Expand Up @@ -1636,7 +1638,7 @@ def _info(self, path: str) -> Info:
lpath = None
info["size"] = self._dir_size(path) if filetype == "dir" else stat.st_size

if not info["mime"] == "directory":
if info["mime"] != "directory":
if self._options["file_url"] and info["read"]:
if lpath:
info["url"] = self._path2url(lpath)
Expand Down
2 changes: 1 addition & 1 deletion imjoy_elfinder/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_one(multi_dict: ImmutableMultiDict, key: str) -> Any:
"""
matched = [v for k, v in multi_dict.items() if k == key]
if len(matched) > 1:
raise KeyError("{} matched more than one key in {}".format(key, multi_dict))
raise KeyError(f"{key} matched more than one key in {multi_dict}")
return next(iter(matched), None)


Expand Down
4 changes: 1 addition & 3 deletions imjoy_elfinder/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def connector(
if os.path.exists(file_path) and not os.path.isdir(file_path):
return FileResponse(file_path, headers=header)

return PlainTextResponse(
"Unable to find: {}".format(request.url), headers=header
)
return PlainTextResponse(f"Unable to find: {request.url}", headers=header)

# get connector output and print it out
if "__text" in response:
Expand Down
2 changes: 1 addition & 1 deletion requirements_lint.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black==21.9b0
flake8==3.9.2
flake8-docstrings==1.6.0
pylint==2.8.3
pylint==2.11.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
README_FILE = ROOT_DIR / "README.md"
LONG_DESCRIPTION = README_FILE.read_text(encoding="utf-8")
VERSION_FILE = ROOT_DIR / "imjoy_elfinder" / "VERSION"
VERSION = json.loads(VERSION_FILE.read_text())["version"]
VERSION = json.loads(VERSION_FILE.read_text(encoding="utf-8"))["version"]

REQUIRES = [
"aiofiles",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_elfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def test_duplicate(
default_context(),
), # Access denied when listing parent files
(
"Unable to create folder: {}".format(Path(ZIP_FILE).stem),
f"Unable to create folder: {Path(ZIP_FILE).stem}",
False,
"zip_file",
"1",
Expand Down

0 comments on commit 80ff1e5

Please sign in to comment.