Fix files
param in http client
Some checks failed
DCO action / DCO (pull_request) Has been cancelled
Some checks failed
DCO action / DCO (pull_request) Has been cancelled
Signed-off-by: Kirill Sosnovskikh <k.sosnovskikh@yadro.com>
This commit is contained in:
parent
b3d05c5c28
commit
df0ac36383
1 changed files with 10 additions and 3 deletions
|
@ -2,7 +2,7 @@ import io
|
|||
import json
|
||||
import logging
|
||||
import logging.config
|
||||
from typing import IO
|
||||
from typing import Mapping, Sequence
|
||||
|
||||
import httpx
|
||||
|
||||
|
@ -84,13 +84,20 @@ class HttpClient:
|
|||
return request_body
|
||||
|
||||
@classmethod
|
||||
def _parse_files(cls, files: dict | None) -> str | None:
|
||||
def _parse_files(cls, files: Mapping | Sequence | None) -> str | None:
|
||||
if not files:
|
||||
return None
|
||||
|
||||
filepaths = {}
|
||||
|
||||
for name, file in files.items():
|
||||
if isinstance(files, Sequence):
|
||||
items = files
|
||||
elif isinstance(files, Mapping):
|
||||
items = files.items()
|
||||
else:
|
||||
raise TypeError(f"'files' must be either Sequence or Mapping, got: {type(files).__name__}")
|
||||
|
||||
for name, file in items:
|
||||
if isinstance(file, io.IOBase):
|
||||
filepaths[name] = file.name
|
||||
|
||||
|
|
Loading…
Reference in a new issue